Guest User

Untitled

a guest
Oct 29th, 2017
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class StartUp
  5. {
  6.     static void Main()
  7.     {
  8.         string pizzaName = Console.ReadLine().Split()[1];
  9.         // Read doughInfo
  10.         string[] doughInfo = Console.ReadLine().Split();
  11.         string flourType = doughInfo[1];
  12.         string bakingTechnique = doughInfo[2];
  13.         double weight = double.Parse(doughInfo[3]);
  14.  
  15.         List<Topping> toppings = new List<Topping>();
  16.        
  17.         while (true)
  18.         {
  19.             string[] toppingInfo = Console.ReadLine().Split();
  20.             if (toppingInfo[0] == "END")
  21.             {
  22.                 break;
  23.             }
  24.             string toppingType = toppingInfo[1];
  25.             double toppingWeight = double.Parse(toppingInfo[2]);
  26.  
  27.             try
  28.             {
  29.                 Topping topping = new Topping(toppingType, toppingWeight);
  30.                 toppings.Add(topping);
  31.             }
  32.             catch (ArgumentException ae)
  33.             {
  34.                 Console.WriteLine(ae.Message);
  35.                 return;
  36.             }
  37.         }
  38.  
  39.         try
  40.         {
  41.             Dough dough = new Dough(flourType, bakingTechnique, weight);
  42.             Pizza pizza = new Pizza(pizzaName, dough, toppings);
  43.             Console.WriteLine($"{pizzaName} - {pizza.CalculateTotalCalories():f2} Calories.");
  44.         }
  45.         catch (ArgumentException ae)
  46.         {
  47.             Console.WriteLine(ae.Message);
  48.             return;
  49.         }
  50.     }
  51. }
Add Comment
Please, Sign In to add comment