static void Main(string[] args) { #region FanFactory //FanFactory fanFactory = new FanFactory(); //var fan1 = fanFactory.CreateFan(FanType.TableFan); //fan1.SwitchOn(); //var fan2 = fanFactory.CreateFan(FanType.CeilingFan); //fan2.SwitchOn(); //var fan3 = fanFactory.CreateFan(FanType.ExhaustFan); //fan3.SwitchOn(); //fan1.SwitchOff(); //fan2.SwitchOff(); //fan3.SwitchOff(); #endregion #region DoorFactory DoorFactory doorFactory = new DoorFactory(); var door1 = doorFactory.MakeDoor(500, 1300); door1.PrintDimensions(); #endregion Console.ReadKey(); }
static void SimpleFactory() { DoorFactory d = new DoorFactory(); Creational.SimpleFactory.WoodenDoor door = DoorFactory.MakeDoor(100, 200);//resolving class name conflicts with adding namespace Console.WriteLine(door.width); Console.WriteLine(door.height); }
public static void Run() { Console.WriteLine("=-=-=-=SimpleFactory=-=-=-="); Console.WriteLine("Make me a door of 100x200"); var door = DoorFactory.MakeDoor(100, 200); Console.WriteLine($"door - Width: {door.GetWidth()}"); Console.WriteLine($"door - Height: {door.GetHeight()}"); Console.WriteLine(); Console.WriteLine("Make me a door of 50x100"); var door2 = DoorFactory.MakeDoor(50, 100); Console.WriteLine($"door2 - Width: {door2.GetWidth()}"); Console.WriteLine($"door2 - Height: {door2.GetHeight()}"); Console.WriteLine("----------------------------------" + Environment.NewLine); }