desislava_topuzakova

Main

Apr 18th, 2020
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Shop
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string input = Console.ReadLine();
  10. //Add, Sell, Update, Calculate, Print
  11. Shop shop = new Shop();
  12.  
  13. while(input.ToLower() != "close")
  14. {
  15. string[] splittedInput = input.Split(" ");
  16. string command = splittedInput[0];
  17.  
  18. switch (command)
  19. {
  20. case "Add":
  21. string addCode = splittedInput[1];
  22. string name = splittedInput[2];
  23. double price = double.Parse(splittedInput[3]);
  24. double addQuantity = double.Parse(splittedInput[4]);
  25. shop.Add(addCode, name, price, addQuantity);
  26. break;
  27. case "Sell":
  28. //code
  29. string sellCode = splittedInput[1];
  30. //quantity
  31. double sellQuantity = double.Parse(splittedInput[2]);
  32. shop.Sell(sellCode, sellQuantity);
  33. break;
  34. case "Update":
  35. //code
  36. string code = splittedInput[1];
  37. //quantity
  38. double quantity = double.Parse(splittedInput[2]);
  39. shop.Update(code, quantity);
  40. break;
  41. case "Calculate":
  42. Console.WriteLine("Total price: " + shop.Calculate());
  43. break;
  44. case "Print":
  45. shop.Print();
  46. break;
  47. }
  48. input = Console.ReadLine();
  49. }
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment