Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Output :: Hello, world!
- Form Created
- Close button created
- Minimize button created
- 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();
- }
- }
- }
Add Comment
Please, Sign In to add comment