static void Main(string[] args) { RestaurantX restaurant = new RestaurantX("MaxDonalds", new CookMaster5000()); bool shouldNotExit = true; while (shouldNotExit) { WriteLine("1. Register order"); WriteLine("2. List pending orders"); WriteLine("3. Process orders"); WriteLine("4. Exit"); ConsoleKeyInfo keyPressed = ReadKey(true); Clear(); switch (keyPressed.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: Write("Dish: "); string dish = ReadLine(); Write("Table: "); string table = ReadLine(); Order newOrder = new Order(dish, table); restaurant.RegisterOrder(newOrder); Clear(); WriteLine("Order registered"); Thread.Sleep(2000); // 2 sek break; case ConsoleKey.D2: case ConsoleKey.NumPad2: WriteLine("Table Dish Registered"); WriteLine("------------------------------------------------------------"); foreach (Order order in restaurant.OrderQueue) { WriteLine($"{order.Table} {order.Dish} {order.RegisteredAt}"); } WriteLine(); WriteLine("Press key to continue"); ReadKey(); break; case ConsoleKey.D3: case ConsoleKey.NumPad3: var completedOrders = restaurant.ProcessOrders(); WriteLine("All orders processed"); Thread.Sleep(2000); break; case ConsoleKey.D4: case ConsoleKey.NumPad4: shouldNotExit = false; break; } Clear(); } }
static void Main(string[] args) { RestaurantX restaurant = new RestaurantX("MaxDonalds"); bool shouldNotExit = true; while (shouldNotExit) { WriteLine("1. Register order"); WriteLine("2. List orders"); WriteLine("3. Exit"); ConsoleKeyInfo keyPressed = ReadKey(true); Clear(); switch (keyPressed.Key) { case ConsoleKey.D1: Write("Dish: "); string dish = ReadLine(); Write("Table: "); string table = ReadLine(); Order newOrder = new Order(dish, table); restaurant.RegisterOrder(newOrder); Clear(); WriteLine("Order registered"); Thread.Sleep(2000); // 2 sek break; case ConsoleKey.D2: WriteLine("Table Dish Registered"); WriteLine("-------------------------------------------------"); foreach (Order order in restaurant.orderQueue) { WriteLine($"{order.Table} {order.Dish} {order.RegisteredAt}"); } WriteLine(); WriteLine("Press key to continue"); ReadKey(); break; case ConsoleKey.D3: shouldNotExit = false; break; } Clear(); } }
static void Main(string[] args) { //LIstor: //Order[] //List<Order> //Queue<Order> FIFO(first in first out) //Stack<Order> LIFO(last in first out) RestaurantX restaurant = new RestaurantX("MaxDonalds"); bool isRunning = true; string dish; string table; while (isRunning) { Console.Clear(); Console.WriteLine("[1] Add order"); Console.WriteLine("[2] List order"); Console.WriteLine("[3] Exit"); ConsoleKeyInfo keyPressed = Console.ReadKey(true); Console.Clear(); switch (keyPressed.Key) { case ConsoleKey.D1: //add order case ConsoleKey.NumPad1: Console.SetCursorPosition(3, 1); Console.WriteLine("Dish: "); Console.SetCursorPosition(3, 2); Console.WriteLine("Table: "); Console.SetCursorPosition("Dish: ".Length, 1); dish = Console.ReadLine(); Console.SetCursorPosition("Table: ".Length, 1); table = Console.ReadLine(); Order neworder = new Order(dish, table); restaurant.RegisterOrder(neworder); Console.Clear(); Console.WriteLine("Order registered!"); Thread.Sleep(2000); break; case ConsoleKey.D2: //list order case ConsoleKey.NumPad2: Console.WriteLine("Table Dish Registered"); Console.WriteLine("________________________________________________________"); foreach (Order order in restaurant.orderQueue) { Console.WriteLine($"{order.Table} {order.Dish} {order.RegisteredAt}"); } Console.WriteLine(); Console.WriteLine(">Press key to continue<"); Console.ReadKey(); break; case ConsoleKey.D3: isRunning = false; break; } } }