Example of Abstract Factory Pattern in C# [on hold]












-1












$begingroup$


I want to know my code about Abstract Factory Pattern is near the principle? My exm is about Windows Explorer that when user run it , new form and other materials in form created .



Please look my code and know me about that.



Output :: Hello, world!
Form Created
Close button created
Minimize button created


//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
public class Program
{
public static void Main(string args)
{
//Your code goes here
Console.WriteLine("Hello, world!");

WindowsFactory formFactory=new Window();
WindowManager wm=new WindowManager(formFactory);
wm.RunForm();


}
}

abstract class WindowsFactory
{
public abstract Form CreateForm();
public abstract Button CreateCloseButton();
public abstract Button CreateMinimizebutton();

}
class Window:WindowsFactory
{
public override Form CreateForm()
{
return new XForm();
}
public override Button CreateCloseButton()
{
return new CloseButton();
}
public override Button CreateMinimizebutton()
{
return new MinimizeButton();
}
}
abstract class Form
{
public abstract void DrawForm();
}
class XForm:Form
{
public override void DrawForm()
{
Console.WriteLine("Form Created");
}
}

abstract class Button
{
public abstract void DrawCloseButton();
public abstract void DrawMinimizeButton();
}
class CloseButton:Button
{
public override void DrawCloseButton()
{
Console.WriteLine("Close button created");
}
public override void DrawMinimizeButton()
{

}
}
class MinimizeButton:Button
{
public override void DrawCloseButton()
{

}
public override void DrawMinimizeButton()
{
Console.WriteLine("Minimize button created");
}
}


class WindowManager
{
private Form _form;
private Button _closeButton;
private Button _minimizeButton;

public WindowManager(WindowsFactory factory)
{
_form=factory.CreateForm();
_closeButton=factory.CreateCloseButton();
_minimizeButton=factory.CreateMinimizebutton();
}
public void RunForm()
{
_form.DrawForm();
_closeButton.DrawCloseButton();
_minimizeButton.DrawMinimizeButton();
}
}

}









share|improve this question









New contributor




iman mohadesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$



put on hold as unclear what you're asking by Toby Speight, t3chb0t, πάντα ῥεῖ, Ludisposed, Sᴀᴍ Onᴇᴌᴀ 13 hours ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.




















    -1












    $begingroup$


    I want to know my code about Abstract Factory Pattern is near the principle? My exm is about Windows Explorer that when user run it , new form and other materials in form created .



    Please look my code and know me about that.



    Output :: Hello, world!
    Form Created
    Close button created
    Minimize button created


    //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.RegularExpressions;

    namespace Rextester
    {
    public class Program
    {
    public static void Main(string args)
    {
    //Your code goes here
    Console.WriteLine("Hello, world!");

    WindowsFactory formFactory=new Window();
    WindowManager wm=new WindowManager(formFactory);
    wm.RunForm();


    }
    }

    abstract class WindowsFactory
    {
    public abstract Form CreateForm();
    public abstract Button CreateCloseButton();
    public abstract Button CreateMinimizebutton();

    }
    class Window:WindowsFactory
    {
    public override Form CreateForm()
    {
    return new XForm();
    }
    public override Button CreateCloseButton()
    {
    return new CloseButton();
    }
    public override Button CreateMinimizebutton()
    {
    return new MinimizeButton();
    }
    }
    abstract class Form
    {
    public abstract void DrawForm();
    }
    class XForm:Form
    {
    public override void DrawForm()
    {
    Console.WriteLine("Form Created");
    }
    }

    abstract class Button
    {
    public abstract void DrawCloseButton();
    public abstract void DrawMinimizeButton();
    }
    class CloseButton:Button
    {
    public override void DrawCloseButton()
    {
    Console.WriteLine("Close button created");
    }
    public override void DrawMinimizeButton()
    {

    }
    }
    class MinimizeButton:Button
    {
    public override void DrawCloseButton()
    {

    }
    public override void DrawMinimizeButton()
    {
    Console.WriteLine("Minimize button created");
    }
    }


    class WindowManager
    {
    private Form _form;
    private Button _closeButton;
    private Button _minimizeButton;

    public WindowManager(WindowsFactory factory)
    {
    _form=factory.CreateForm();
    _closeButton=factory.CreateCloseButton();
    _minimizeButton=factory.CreateMinimizebutton();
    }
    public void RunForm()
    {
    _form.DrawForm();
    _closeButton.DrawCloseButton();
    _minimizeButton.DrawMinimizeButton();
    }
    }

    }









    share|improve this question









    New contributor




    iman mohadesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$



    put on hold as unclear what you're asking by Toby Speight, t3chb0t, πάντα ῥεῖ, Ludisposed, Sᴀᴍ Onᴇᴌᴀ 13 hours ago


    Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


















      -1












      -1








      -1





      $begingroup$


      I want to know my code about Abstract Factory Pattern is near the principle? My exm is about Windows Explorer that when user run it , new form and other materials in form created .



      Please look my code and know me about that.



      Output :: Hello, world!
      Form Created
      Close button created
      Minimize button created


      //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5



      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text.RegularExpressions;

      namespace Rextester
      {
      public class Program
      {
      public static void Main(string args)
      {
      //Your code goes here
      Console.WriteLine("Hello, world!");

      WindowsFactory formFactory=new Window();
      WindowManager wm=new WindowManager(formFactory);
      wm.RunForm();


      }
      }

      abstract class WindowsFactory
      {
      public abstract Form CreateForm();
      public abstract Button CreateCloseButton();
      public abstract Button CreateMinimizebutton();

      }
      class Window:WindowsFactory
      {
      public override Form CreateForm()
      {
      return new XForm();
      }
      public override Button CreateCloseButton()
      {
      return new CloseButton();
      }
      public override Button CreateMinimizebutton()
      {
      return new MinimizeButton();
      }
      }
      abstract class Form
      {
      public abstract void DrawForm();
      }
      class XForm:Form
      {
      public override void DrawForm()
      {
      Console.WriteLine("Form Created");
      }
      }

      abstract class Button
      {
      public abstract void DrawCloseButton();
      public abstract void DrawMinimizeButton();
      }
      class CloseButton:Button
      {
      public override void DrawCloseButton()
      {
      Console.WriteLine("Close button created");
      }
      public override void DrawMinimizeButton()
      {

      }
      }
      class MinimizeButton:Button
      {
      public override void DrawCloseButton()
      {

      }
      public override void DrawMinimizeButton()
      {
      Console.WriteLine("Minimize button created");
      }
      }


      class WindowManager
      {
      private Form _form;
      private Button _closeButton;
      private Button _minimizeButton;

      public WindowManager(WindowsFactory factory)
      {
      _form=factory.CreateForm();
      _closeButton=factory.CreateCloseButton();
      _minimizeButton=factory.CreateMinimizebutton();
      }
      public void RunForm()
      {
      _form.DrawForm();
      _closeButton.DrawCloseButton();
      _minimizeButton.DrawMinimizeButton();
      }
      }

      }









      share|improve this question









      New contributor




      iman mohadesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I want to know my code about Abstract Factory Pattern is near the principle? My exm is about Windows Explorer that when user run it , new form and other materials in form created .



      Please look my code and know me about that.



      Output :: Hello, world!
      Form Created
      Close button created
      Minimize button created


      //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5



      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text.RegularExpressions;

      namespace Rextester
      {
      public class Program
      {
      public static void Main(string args)
      {
      //Your code goes here
      Console.WriteLine("Hello, world!");

      WindowsFactory formFactory=new Window();
      WindowManager wm=new WindowManager(formFactory);
      wm.RunForm();


      }
      }

      abstract class WindowsFactory
      {
      public abstract Form CreateForm();
      public abstract Button CreateCloseButton();
      public abstract Button CreateMinimizebutton();

      }
      class Window:WindowsFactory
      {
      public override Form CreateForm()
      {
      return new XForm();
      }
      public override Button CreateCloseButton()
      {
      return new CloseButton();
      }
      public override Button CreateMinimizebutton()
      {
      return new MinimizeButton();
      }
      }
      abstract class Form
      {
      public abstract void DrawForm();
      }
      class XForm:Form
      {
      public override void DrawForm()
      {
      Console.WriteLine("Form Created");
      }
      }

      abstract class Button
      {
      public abstract void DrawCloseButton();
      public abstract void DrawMinimizeButton();
      }
      class CloseButton:Button
      {
      public override void DrawCloseButton()
      {
      Console.WriteLine("Close button created");
      }
      public override void DrawMinimizeButton()
      {

      }
      }
      class MinimizeButton:Button
      {
      public override void DrawCloseButton()
      {

      }
      public override void DrawMinimizeButton()
      {
      Console.WriteLine("Minimize button created");
      }
      }


      class WindowManager
      {
      private Form _form;
      private Button _closeButton;
      private Button _minimizeButton;

      public WindowManager(WindowsFactory factory)
      {
      _form=factory.CreateForm();
      _closeButton=factory.CreateCloseButton();
      _minimizeButton=factory.CreateMinimizebutton();
      }
      public void RunForm()
      {
      _form.DrawForm();
      _closeButton.DrawCloseButton();
      _minimizeButton.DrawMinimizeButton();
      }
      }

      }






      c# design-patterns






      share|improve this question









      New contributor




      iman mohadesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      iman mohadesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 44 mins ago







      iman mohadesi













      New contributor




      iman mohadesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 19 hours ago









      iman mohadesiiman mohadesi

      11




      11




      New contributor




      iman mohadesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      iman mohadesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      iman mohadesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      put on hold as unclear what you're asking by Toby Speight, t3chb0t, πάντα ῥεῖ, Ludisposed, Sᴀᴍ Onᴇᴌᴀ 13 hours ago


      Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






      put on hold as unclear what you're asking by Toby Speight, t3chb0t, πάντα ῥεῖ, Ludisposed, Sᴀᴍ Onᴇᴌᴀ 13 hours ago


      Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
























          0






          active

          oldest

          votes

















          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes

          Popular posts from this blog

          How to make a Squid Proxy server?

          Is this a new Fibonacci Identity?

          19世紀