private static void InitializeMenu(Menu currentMenu) { currentMenu.AddDrink(1, new CaffeAmericanoDrinkBuilder()); currentMenu.AddDrink(2, new CaffeLatteDrinkBuilder()); currentMenu.AddDrink(3, new CaffeMochaDrinkBuilder()); currentMenu.AddDrink(4, new CappuccinoDrinkBuilder()); currentMenu.AddDrink(5, new CoffeeDrinkBuilder()); currentMenu.AddDrink(6, new DecafCoffeeDrinkBuilder()); }
static void Main(string[] args) { ConsoleKeyInfo command; InventoryControl inventoryControl = new InventoryControl(); Menu currentMenu = new Menu(); var currentInventory = inventoryControl.CreateResetInventory(); InitializeMenu(currentMenu); inventoryControl.DisplayInventoryLevels(); currentMenu.DisplayMenu(inventoryControl); command = Console.ReadKey(true); while (command.Key != ConsoleKey.Q) { if (command.Key == ConsoleKey.R) { currentInventory = inventoryControl.CreateResetInventory(); Console.WriteLine(); inventoryControl.DisplayInventoryLevels(); currentMenu.DisplayMenu(inventoryControl); } else { int selection; bool menuItemSelected = Int32.TryParse(command.KeyChar.ToString(), out selection); if (menuItemSelected) { DrinkMaker drinkMaker = new DrinkMaker(); var currentMenuDrink = currentMenu.GetMenuDrink(selection); if (currentMenuDrink != null) { drinkMaker.MakeDrink(currentMenu.GetMenuDrink(selection), inventoryControl); inventoryControl.DisplayInventoryLevels(); currentMenu.DisplayMenu(inventoryControl); } else { Console.WriteLine("\nInvalid selection: {0}", command.KeyChar); } } else { Console.WriteLine("\nInvalid selection: {0}", command.KeyChar); } } command = Console.ReadKey(true); } }