static void Main(string[] args) { Console.WriteLine("------------"); AppleBuilder computerBuilder = new AppleBuilder(); ComputerShop computerShop = new ComputerShop(); computerShop.ConstructComputer(computerBuilder); computerBuilder.Computer.DisplayConfiguration(); Console.WriteLine("------------"); LaptopBuilder laptopBuilder = new LaptopBuilder(); ComputerShop laptopShop = new ComputerShop(); laptopShop.ConstructComputer(laptopBuilder); laptopBuilder.Computer.DisplayConfiguration(); Console.WriteLine("------------"); DesktopBuilder desktopBuilder = new DesktopBuilder(); ComputerShop desktopShop = new ComputerShop(); desktopShop.ConstructComputer(desktopBuilder); desktopBuilder.Computer.DisplayConfiguration(); Console.ReadLine(); LaptopBuilder laptopBuilder = new LaptopBuilder(); ComputerShop laptopShop = new ComputerShop(); laptopShop.ConstructComputer(laptopBuilder); laptopBuilder.Computer.DisplayConfiguration(); }
static void Main(string[] args) { IMachineFactory factory = new HighBudgetMachine();// Or new LowBudgetMachine(); ComputerShop shop = new ComputerShop(factory); shop.AssembleMachine(); }
static void Main(string[] args) { ComputerShop cp = new ComputerShop("Elgiganten"); cp.addComputer(new Router("ASUS Router", 115, 8, 12)); cp.addComputer(new Laptop("ASUS Laptop", 500, 16, 24, "Bose", 32000)); cp.addComputer(new Phone("Iphone", 128, 8, 6, 16000, 80)); cp.addComputer(new Server("Homelab Server", 10000, 100, "AMD epyc 7742", 64, 3.4)); // Virtual calls foreach (KeyValuePair <string, Computer> c in cp.computers) { c.Value.systemCheck(); } // Abstract calls foreach (KeyValuePair <string, Computer> c in cp.computers) { Console.WriteLine(c.Value.GetDescription()); } }