daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Jan 15th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Output :: Hello, world!
  2.           Form Created
  3.           Close button created
  4.           Minimize button created
  5.    
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text.RegularExpressions;
  10.  
  11. namespace Rextester
  12. {
  13.     public class Program
  14.     {
  15.         public static void Main(string[] args)
  16.         {
  17.             //Your code goes here
  18.             Console.WriteLine("Hello, world!");
  19.  
  20.             WindowsFactory formFactory=new Window();
  21.            WindowManager wm=new WindowManager(formFactory);
  22.             wm.RunForm();
  23.  
  24.  
  25.         }
  26.     }
  27.  
  28.     abstract class WindowsFactory
  29.     {
  30.         public abstract Form CreateForm();
  31.         public abstract Button CreateCloseButton();
  32.         public abstract Button CreateMinimizebutton();
  33.  
  34.     }
  35.    class Window:WindowsFactory
  36.    {
  37.        public override Form CreateForm()
  38.        {
  39.           return new XForm();
  40.        }
  41.        public override Button CreateCloseButton()
  42.        {
  43.            return new CloseButton();
  44.        }
  45.        public override Button CreateMinimizebutton()
  46.        {
  47.            return new MinimizeButton();
  48.        }
  49.    }
  50.    abstract class Form
  51.    {
  52.         public abstract void DrawForm();
  53.    }
  54.     class XForm:Form
  55.     {
  56.         public override void DrawForm()
  57.         {
  58.             Console.WriteLine("Form Created");
  59.         }
  60.     }
  61.  
  62.     abstract class Button
  63.     {
  64.         public abstract void DrawCloseButton();
  65.         public abstract void DrawMinimizeButton();
  66.     }
  67.     class CloseButton:Button
  68.     {
  69.         public override void DrawCloseButton()
  70.         {
  71.             Console.WriteLine("Close button created");
  72.         }
  73.         public override void DrawMinimizeButton()
  74.         {
  75.  
  76.         }
  77.     }
  78.     class MinimizeButton:Button
  79.     {
  80.         public override void DrawCloseButton()
  81.         {
  82.  
  83.         }
  84.         public override void DrawMinimizeButton()
  85.         {
  86.             Console.WriteLine("Minimize button created");
  87.         }
  88.     }
  89.  
  90.  
  91.     class WindowManager
  92.     {
  93.         private Form _form;
  94.         private Button _closeButton;
  95.         private Button _minimizeButton;
  96.  
  97.         public WindowManager(WindowsFactory factory)
  98.         {
  99.             _form=factory.CreateForm();
  100.             _closeButton=factory.CreateCloseButton();
  101.             _minimizeButton=factory.CreateMinimizebutton();
  102.         }
  103.         public void RunForm()
  104.         {
  105.             _form.DrawForm();
  106.             _closeButton.DrawCloseButton();
  107.             _minimizeButton.DrawMinimizeButton();
  108.         }
  109.     }
  110.  
  111. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top