Advertisement
Guest User

Engine

a guest
Jul 30th, 2019
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace PizzaCalories
  6. {
  7. public class Engine
  8. {
  9. public void Run()
  10. {
  11. try
  12. {
  13. string[] pizzaTokens = Console.ReadLine().
  14. Split(" ", StringSplitOptions.RemoveEmptyEntries);
  15.  
  16. string pizzaName = pizzaTokens[1];
  17.  
  18. string[] doughTokens = Console.ReadLine().
  19. Split(" ", StringSplitOptions.RemoveEmptyEntries);
  20.  
  21. string doughName = doughTokens[1];
  22. string bakeType = doughTokens[2];
  23. double doughWeight = double.Parse(doughTokens[3]);
  24.  
  25. Dough dough = new Dough(doughName, bakeType, doughWeight);
  26.  
  27. Pizza pizza = new Pizza(pizzaName, dough);
  28.  
  29. string command = Console.ReadLine();
  30.  
  31. while (command.ToUpper() != "END")
  32. {
  33. string[] toppingTokens = command.
  34. Split(" ", StringSplitOptions.RemoveEmptyEntries);
  35.  
  36. string toppingName = toppingTokens[1];
  37. double toppingWeight = double.Parse(toppingTokens[2]);
  38.  
  39. Topping topping = new Topping(toppingName, toppingWeight);
  40.  
  41. pizza.AddTopping(topping);
  42.  
  43. command = Console.ReadLine();
  44. }
  45.  
  46. Console.WriteLine(pizza);
  47. }
  48. catch (Exception ae)
  49. {
  50. Console.WriteLine(ae.Message);
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement