Advertisement
Guest User

Untitled

a guest
Nov 7th, 2021
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PizzaCalories
  4. {
  5. public class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. string pizzaName = Console.ReadLine().Split()[1];
  10.  
  11. string[] doughData = Console.ReadLine().Split();
  12. string flourType = doughData[1];
  13. string bakingTechniques = doughData[2];
  14. int weight = int.Parse(doughData[3]);
  15.  
  16. try
  17. {
  18. Dough dough = new Dough(flourType, bakingTechniques, weight);
  19. Pizza pizza = new Pizza(pizzaName, dough);
  20.  
  21. while (true)
  22. {
  23. string line = Console.ReadLine();
  24.  
  25. if (line == "END")
  26. {
  27. break;
  28. }
  29.  
  30. string[] partsTopping = line.Split();
  31.  
  32. string toppingName = partsTopping[1];
  33. int toppingWeight = int.Parse(partsTopping[2]);
  34.  
  35. Topping topping = new Topping(toppingName, toppingWeight);
  36.  
  37. pizza.AddTopping(topping);
  38.  
  39. }
  40.  
  41. Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():F2} Calories.");
  42. }
  43. catch (Exception ex)
  44. {
  45. Console.WriteLine(ex.Message);
  46. }
  47. }
  48. }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement