static void Main(string[] args) { CoffeeMachine PMCoffee = new CoffeeMachine(); Console.WriteLine("Are you client?"); string answer = Console.ReadLine(); if (answer.Equals("yes", StringComparison.OrdinalIgnoreCase)) { ClientMode(PMCoffee); } else { Console.WriteLine("If you're admin,please enter the password"); if (!PMCoffee.CheckPassword(Console.ReadLine())) { Console.WriteLine("Incorrect password!"); } else { AdminMode(PMCoffee); } } Console.ReadLine(); }
/// <summary> /// Includes all methods for work with client (i.e coffee preparation). /// </summary> /// <param name="coffeeMachine">Particular coffeemachine.</param> public static void ClientMode(CoffeeMachine coffeeMachine) { string method; int sugar; int addNumber; double summary = 0; Console.WriteLine("What kind of coffee would you like?"); coffeeMachine.ShowMenu(); method = Console.ReadLine(); Console.WriteLine("And what about any additives?Choose, how many do you want"); coffeeMachine.ShowAdds(); addNumber = Convert.ToInt32(Console.ReadLine()); Dictionary <string, double> additives = new Dictionary <string, double>(addNumber); if (addNumber != 0) { Console.WriteLine("Great!Now choose them"); for (int i = 0; i < addNumber; ++i) { additives.Add(Console.ReadLine(), i); } } Console.WriteLine("Last question for now-how many sugar cubes you want in your drink?"); sugar = Convert.ToInt32(Console.ReadLine()); Coffee coffee = addNumber != 0 ? coffeeMachine.GetCoffee(method, additives, sugar) : coffeeMachine.GetCoffee(method, sugar); summary += coffeeMachine.CookMethods[method]; if (addNumber != 0) { foreach (var add in additives) { summary += coffeeMachine.Additives[add.Key]; } } Console.WriteLine("You coffee's cost is {0}", summary); Console.WriteLine("Chosen additives and their price:"); if (addNumber == 0) { Console.WriteLine("No additives - 0"); } else { foreach (var add in additives) { Console.WriteLine("{0} - {1}", add.Key, coffeeMachine.Additives[add.Key]); } } Console.WriteLine("Sugar amount:{0}", sugar); Console.WriteLine("Thanks for visiting!"); }
static void Main(string[] args) { CoffeeMachine HoGuomCoffeeMachine = new CoffeeMachine(); HoGuomCoffeeMachine.CokeSize = CoffeeSize.Biggest; double price = HoGuomCoffeeMachine.CalcPrice(); Console.WriteLine("Price of your coffee is {0}", price); Console.WriteLine("Wellcome back"); }
/// <summary> /// Includes all methods for admin's work (i.e change machine's menu). /// </summary> /// <param name="coffeeMachine">Particular coffeemachine.</param> public static void AdminMode(CoffeeMachine coffeeMachine) { Console.WriteLine(@"Welcome back! Choose the options: 1-add new method; 2-add new additive; 3-delete method; 4-delete additive; 5-change the cost of method; 6-change the cost of additive;"); int answer = Convert.ToInt32(Console.ReadLine()); switch (answer) { case 1: Console.WriteLine("Enter new method and its price"); string method = Console.ReadLine(); double metPrice = Convert.ToInt32(Console.ReadLine()); coffeeMachine.AddMethod(method, metPrice); break; case 2: Console.WriteLine("Enter new additive and its price"); string additive = Console.ReadLine(); double addPrice = Convert.ToInt32(Console.ReadLine()); coffeeMachine.AddAdditive(additive, addPrice); break; case 3: Console.WriteLine("Enter method"); string deleteMethod = Console.ReadLine(); coffeeMachine.DeleteMethod(deleteMethod); break; case 4: Console.WriteLine("Enter additive"); string deleteAdditive = Console.ReadLine(); coffeeMachine.DeleteAdditive(deleteAdditive); break; case 5: Console.WriteLine("Enter method and its new price"); string oldMethod = Console.ReadLine(); double newMetPrice = Convert.ToInt32(Console.ReadLine()); coffeeMachine.ChangeMethodPrice(oldMethod, newMetPrice); break; case 6: Console.WriteLine("Enter method and its new price"); string oldAdditive = Console.ReadLine(); double newAddPrice = Convert.ToInt32(Console.ReadLine()); coffeeMachine.ChangeAdditivePrice(oldAdditive, newAddPrice); break; default: Console.WriteLine("Incorrect option!"); break; } Console.WriteLine("Do you want to continue?"); if (Console.ReadLine().Equals("yes", StringComparison.OrdinalIgnoreCase)) { AdminMode(coffeeMachine); } else { Console.WriteLine("Good day!"); } }