private static void Main(string[] args) { var pizzaTokens = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); if (pizzaTokens.Length > 1) { pizzaName = pizzaTokens[1]; } var inputTokens = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); Pizza pizza = new Pizza(); try { while (inputTokens[0] != "END") { if (inputTokens[0] == "Dough") { var dough = new Dough(inputTokens[1], inputTokens[2], int.Parse(inputTokens[3])); doughCalories = dough.Calories(); pizza = new Pizza(pizzaName, dough); } else if (inputTokens[0] == "Topping") { var topping = new Topping(inputTokens[1], int.Parse(inputTokens[2])); toppingCalories += topping.Calories(); pizza.AddTopping(topping); } inputTokens = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); Environment.Exit(0); } var totalCalories = doughCalories + toppingCalories; Console.WriteLine($"{pizzaName} - {totalCalories:f2} Calories."); }
static void Main(string[] args) { flourTypes = new Dictionary <string, double> { { "white", 1.5 }, { "wholegrain", 1.0 } }; backingTechniques = new Dictionary <string, double>() { { "crispy", 0.9 }, { "chewy", 1.1 }, { "homemade", 1 } }; toppingTypes = new Dictionary <string, double>() { { "meat", 1.2 }, { "veggies", 0.8 }, { "cheese", 1.1 }, { "sauce", 0.9 } }; string input = ""; try { string[] pizzaInfo = Console.ReadLine().Split(' '); Pizza pizza = new Pizza(pizzaInfo[1]); string[] doughInfo = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); Dough dough = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3])); pizza.Dough = dough; while ((input = Console.ReadLine()) != "END") { string[] data = input.Split(' ', StringSplitOptions.RemoveEmptyEntries); string command = data[0]; string type = data[1]; double weight = double.Parse(data[2]); Topping topping = new Topping(type, weight); pizza.AddTopping(topping); } Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:F2} Calories."); } catch (ArgumentException exception) { Console.WriteLine(exception.Message); return; } }
public void AddTopping(Topping topping) { if (toppings.Count == 10) { Exception exs = new Exception("Number of toppings should be in range [0..10]."); Console.WriteLine(exs.Message); Environment.Exit(0); } else { toppings.Add(topping); } }
private static void AddTopping(Pizza pizza) { string toppingInfo; while ((toppingInfo = Console.ReadLine()) != "END") { var toppingArgs = toppingInfo.Split(); var type = toppingArgs[1]; var weight = decimal.Parse(toppingArgs[2]); var topping = new Topping(type, weight); pizza.AddTopping(topping); } }
static void Main(string[] args) { try { string input = Console.ReadLine(); var pizzaName = input.Split(" "); var name = pizzaName[1]; Pizza pizza = new Pizza(name); while (true) { input = Console.ReadLine(); if (input.Equals("END")) { break; } var tokken = input.Split(" ", StringSplitOptions.RemoveEmptyEntries); var @case = tokken[0]; try { switch (@case.ToLower()) { case "dough": var flour = tokken[1]; var baking = tokken[2]; var weightDought = double.Parse(tokken[3]); Dough dough = new Dough(flour, baking, weightDought); pizza.Dough = dough; break; case "topping": var product = tokken[1]; var weight = double.Parse(tokken[2]); var topping = new Topping(product, weight); pizza.GetTopping(topping); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); return; } } Console.WriteLine(pizza); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } }
static void Main(string[] args) { try { List <string> pizzaNameInfo = Console.ReadLine() .Split(' ') .ToList(); string pizzaName = pizzaNameInfo[1]; List <string> inputInfoDough = Console.ReadLine() .Split(' ') .ToList(); string flourType = inputInfoDough[1]; string bakingTechnique = inputInfoDough[2]; double flourWeight = double.Parse(inputInfoDough[3]); Dough dough = new Dough(flourType, bakingTechnique, flourWeight); Pizza pizza = new Pizza(pizzaName, dough); while (true) { string input = Console.ReadLine(); if (input == "END") { break; } List <string> inputInfoTopping = input .Split(' ') .ToList(); string toppingType = inputInfoTopping[1]; double toppingWeight = double.Parse(inputInfoTopping[2]); Topping topping = new Topping(toppingType, toppingWeight); pizza.AddTopping(topping); } Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories():F2} Calories."); } catch (Exception exception) { Console.WriteLine(exception.Message); } }
private static void ReadTopping(string input) { var inputArgs = input.Split(); if (inputArgs[0] != "Topping") { return; } var toppingName = inputArgs[1]; var weight = decimal.Parse(inputArgs[2]); Topping topping = new Topping(toppingName, weight); Toppings.Add(topping); }
public static void Main(string[] args) { Pizza newPizza = new Pizza(); Dough newDoght = new Dough(); Topping newToping = new Topping(); string[] pizzaTokken = Console.ReadLine().Split(" "); string pizzaName = pizzaTokken[1]; string[] TokenDought = Console.ReadLine().Split(" "); try { newDoght = GetNewDought(TokenDought); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } try { newPizza = new Pizza(pizzaName, newDoght); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } while (true) { string[] toppings = Console.ReadLine().Split(" "); if (toppings[0] == "END") { break; } try { newToping = GetNewTopping(toppings); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } newPizza.AddToppings(newToping); } Console.WriteLine(newPizza); }
public static void Main() { try { string[] inputPizza = Console.ReadLine() .Split(); string pizzaName = inputPizza[1]; string input = Console.ReadLine(); string[] arguments = input .Split(); string typeProduct = arguments[0]; string flourType = arguments[1]; string bakingTechnique = arguments[2]; double weight = double.Parse(arguments[3]); Dough dough = new Dough(flourType, bakingTechnique, weight); Pizza pizza = new Pizza(pizzaName, dough); while (true) { string inputToping = Console.ReadLine(); if (inputToping == "END") { break; } string[] argumenrsTopiing = inputToping .Split(); string typeProduct2 = argumenrsTopiing[0]; string typeTopiing = argumenrsTopiing[1]; double weightTopiing = double.Parse(argumenrsTopiing[2]); Topping topping = new Topping(typeTopiing, weightTopiing); pizza.AddTopping(topping); } Console.WriteLine(pizza); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private static Topping CreateTopping(string input) { Topping topping; string[] toppingInput = input .Split() .ToArray(); string toppingType = toppingInput[1]; int weight = int.Parse(toppingInput[2]); topping = new Topping(toppingType, weight); return(topping); }
static Topping CreateTopping(string command) { Topping topping = null; string[] toppingInput = command.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); try { topping = new Topping(toppingInput[1], double.Parse(toppingInput[2])); } catch (ArgumentException ae) { throw ae; } return(topping); }
static void Main(string[] args) { string inputLine = Console.ReadLine(); while (inputLine != "END") { string[] tokens = inputLine.Split(); string productType = tokens[0]; try { switch (productType) { case "Dough": Dough dough = new Dough(tokens[1], tokens[2], double.Parse(tokens[3])); Console.WriteLine($"{dough.Calories:F2}"); break; case "Topping": Topping topping = new Topping(tokens[1], double.Parse(tokens[2])); Console.WriteLine($"{topping.Calories:F2}"); break; case "Pizza": Pizza pizza = new Pizza(tokens[1], int.Parse(tokens[2])); string[] doughArgs = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); pizza.Dough = new Dough(doughArgs[1], doughArgs[2], double.Parse(doughArgs[3])); for (int i = 0; i < pizza.NumberOfToppings; i++) { string[] toppingArgs = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); pizza.AddTopping(new Topping(toppingArgs[1], double.Parse(toppingArgs[2]))); } Console.WriteLine(pizza); break; } } catch (ArgumentException argumentException) { Console.WriteLine(argumentException.Message); Environment.Exit(1); } inputLine = Console.ReadLine(); } }
public void AddTopping(Topping topping) { try { if (toppings.Count() >= 10) { throw new InvalidOperationException("Number of toppings should be in range [0..10]."); } this.toppings.Add(topping); } catch (Exception e) { Console.WriteLine(e.Message); throw; } }
private static void AddToppingsToPizza(Pizza pizza) { string command; while ((command = Console.ReadLine()) != "END") { string[] toppingArgs = command .Split() .Skip(1) .ToArray(); string toppingType = toppingArgs[0]; double toppingWeight = double.Parse(toppingArgs[1]); Topping topping = new Topping(toppingType, toppingWeight); pizza.AddTopping(topping); } }
private static void AddToppings(Pizza pizza) { string input; while ((input = Console.ReadLine()) != "END") { string[] toppingArguments = input.Split(); string toppingType = toppingArguments[1]; double toppingWeight = double.Parse(toppingArguments[2]); Topping topping = new Topping(toppingType, toppingWeight); pizza.AddTopping(topping); } }
private static Pizza MakePizza(string name, int numberOfToppings) { var pizza = new Pizza(name, numberOfToppings); var doughInfo = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); pizza.Dough = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3])); for (int i = 0; i < numberOfToppings; i++) { var toppingInfo = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var topping = new Topping(toppingInfo[1], int.Parse(toppingInfo[2])); pizza.AddTopping(topping); } return(pizza); }
public static void Main() { try { double allCalories = 0; string pizzaInput = Console.ReadLine(); string[] pizzaToken = pizzaInput.Split(); if (string.IsNullOrWhiteSpace(pizzaToken[1]) || pizzaToken[1].Length > 15) { throw new ArgumentException("Pizza name should be between 1 and 15 symbols."); } var pizza = new Pizza(pizzaToken[1]); string doughInput = Console.ReadLine(); string[] doughToken = doughInput.Split(); string flourType = doughToken[1]; string bakingTechnique = doughToken[2]; double weightDough = double.Parse(doughToken[3]); var dough = new Dough(flourType, bakingTechnique, weightDough); dough.ClaculateCalories(); allCalories += dough.Calories; string toppingInput = Console.ReadLine(); while (toppingInput != "END") { string[] toppingToken = toppingInput.Split(); string type = toppingToken[1]; double weightTopping = double.Parse(toppingToken[2]); var topping = new Topping(type, weightTopping); pizza.Toppings(topping); topping.CalculateCalories(); allCalories += topping.Calories; toppingInput = Console.ReadLine(); } Console.WriteLine($"{pizzaToken[1]} - {allCalories:f2} Calories."); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } }
private static void MakePizza(string[] tokens) { var pizza = new Pizza(tokens[1], int.Parse(tokens[2])); var doughInfo = Console.ReadLine().Split(); var dough = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3])); pizza.Dough = dough; var numberOfToppings = int.Parse(tokens[2]); for (int i = 0; i < numberOfToppings; i++) { var toppingInfo = Console.ReadLine().Split(); var topping = new Topping(toppingInfo[1], double.Parse(toppingInfo[2])); pizza.AddTopping(topping); } Console.WriteLine($"{pizza.Name} - {pizza.getCalories():F2} Calories."); }
public static void Main() { try { Pizza pizza = null; string input; while ((input = Console.ReadLine()) != "END") { string[] data = input .Split(' '); string command = data[0]; switch (command) { case "Pizza": string pizzaName = data[1]; pizza = new Pizza(pizzaName); break; case "Dough": string flourType = data[1]; string bakingTechnique = data[2]; double doughWeight = double.Parse(data[3]); Dough dough = new Dough(flourType, bakingTechnique, doughWeight); pizza.AddDough(dough); break; case "Topping": string toppingType = data[1]; double toppingWeight = double.Parse(data[2]); Topping topping = new Topping(toppingType, toppingWeight); pizza.AddTopping(topping); break; } } Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:f2} Calories."); } catch (Exception e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { string command = Console.ReadLine(); Dough dough = new Dough(); string name = ""; try { string[] arr = command.Split(); name = arr[1]; arr = Console.ReadLine().Split(); string flowerType = arr[1]; string technique = arr[2]; decimal weight = decimal.Parse(arr[3]); Pizza pizza = new Pizza(name, new Dough(flowerType, technique, weight)); command = Console.ReadLine(); while (command != "END") { arr = command.Split(); string type = arr[0]; switch (type) { case "Topping": string toppingType = arr[1]; decimal toppingWeight = decimal.Parse(arr[2]); Topping topping = new Topping(toppingType, toppingWeight); pizza.AddTopping(topping); break; } command = Console.ReadLine(); } Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():f2} Calories."); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Main(string[] args) { try { string[] inputCommand = Console.ReadLine().Split(); string pizzaName = inputCommand[1]; string[] inputInfo = Console.ReadLine().Split().ToArray(); string doughType = inputInfo[1].ToLower(); string bakingTehnique = inputInfo[2].ToLower(); double weight = double.Parse(inputInfo[3]); Dough dough = new Dough(doughType, bakingTehnique, weight); Pizza pizza = new Pizza(pizzaName, dough); while (true) { string inputArg = Console.ReadLine(); if (inputArg.Equals("END")) { break; } string[] input = inputArg.Split().ToArray(); string toppingType = input[1]; double toppingWeight = double.Parse(input[2]); Topping topping = new Topping(toppingType, toppingWeight); pizza.AddTopping(topping); //pizza.GetTotalPizzaCalories(); } Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:f2} Calories."); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Main(string[] args) { try { string pizzaName = Console.ReadLine() .Split()[1]; string[] doughInput = Console.ReadLine() .Split() .ToArray(); string flourType = doughInput[1]; string bakingTechnique = doughInput[2]; double weight = double.Parse(doughInput[3]); Dough dough = new Dough(flourType, bakingTechnique, weight); Pizza pizza = new Pizza(pizzaName, dough); string command = Console.ReadLine(); while (command != "END") { string[] inputTopping = command .Split() .ToArray(); string toppingProduct = inputTopping[1]; double weightOfTopping = double.Parse(inputTopping[2]); Topping topping = new Topping(toppingProduct, weightOfTopping); pizza.AddTopping(topping); command = Console.ReadLine(); } Console.WriteLine($"{pizza.Name} - {pizza.PizzaTotalCalories:F2} Calories."); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { string[] productName = Console.ReadLine().Split(); string pizzaName = productName[1]; var dough = Console.ReadLine().Split(); Dough baseDough; /*= new Dough(dough[1],dough[2],double.Parse(dough[3]));*/ try { baseDough = new Dough(dough[1], dough[2], double.Parse(dough[3])); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } baseDough = new Dough(dough[1], dough[2], double.Parse(dough[3])); Pizza pizza = new Pizza(pizzaName) { Dough = baseDough }; string input; while ((input = Console.ReadLine()) != "END") { var tokens = input.Split(); Topping topping; try { topping = new Topping(tokens[1], double.Parse(tokens[2])); pizza.ListOfTopings(topping); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } //topping = new Topping(tokens[1], double.Parse(tokens[2])); } Console.WriteLine(pizza); }
static void Main(string[] args) { try { while (true) { string cmd = Console.ReadLine(); if (cmd == "END") { break; } string[] cmdArgs = cmd.Split(); string type = cmdArgs[0]; if (type == "Dough") { string flourType = cmdArgs[1]; string backingType = cmdArgs[2]; double weight = double.Parse(cmdArgs[3]); dough = new Dough(flourType, backingType, weight); pizza = new Pizza(pizzaName, dough); } else if (type == "Topping") { string toppingType = cmdArgs[1]; double weight = double.Parse(cmdArgs[2]); Topping topping = new Topping(toppingType, weight); pizza.AddTopping(topping); } else if (type == "Pizza") { pizzaName = cmdArgs[1]; } } Console.WriteLine(pizza); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } }
public void Run() { Dough dough = null; Topping topping = null; Pizza pizza = null; try { string input = Console.ReadLine(); while (input != "end") { var pizzaInput = input.Split(); string pizzaName = pizzaInput[1]; input = Console.ReadLine().ToLower(); dough = CreateDough(input); pizza = new Pizza(pizzaName, dough); input = Console.ReadLine().ToLower(); while (input != "end") { topping = CreateTopping(input); pizza.AddTopping(topping); input = Console.ReadLine().ToLower(); } } //Console.WriteLine($"{dough.GetTotalCalories():F2}"); //Console.WriteLine($"{topping.GetTotalCalories():F2}"); double result = pizza.GetTotalCalories(); Console.WriteLine($"{pizza.Name} - {result:F2} Calories."); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Main(string[] args) { try { var pizzaParameters = Console.ReadLine() .Split(); var pizzaName = pizzaParameters[1]; var doughParameters = Console.ReadLine() .Split(); var flourType = doughParameters[1]; var bakingTechnique = doughParameters[2]; var grams = double.Parse(doughParameters[3]); var dough = new Dough(flourType, bakingTechnique, grams); var pizza = new Pizza(pizzaName, dough); while (true) { var inputLine = Console.ReadLine(); if (inputLine == "END") { break; } var toppingParameters = inputLine .Split(); var toppingName = toppingParameters[1]; var toppingGrams = double.Parse(toppingParameters[2]); var topping = new Topping(toppingName, toppingGrams); pizza.AddTopping(topping); } Console.WriteLine($"{pizza.Name} - {pizza.CalculateCalories():F2} Calories."); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } }
public static void Main(string[] args) { string[] pizzaOrder = Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] supplements = Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); try { string name = pizzaOrder[1]; string flourType = supplements[1]; string backingTechnique = supplements[2]; int weight = int.Parse(supplements[3]); Dough dough = new Dough(flourType, backingTechnique, weight); Pizza pizza = new Pizza(name, dough); string command = Console.ReadLine(); while (command != "END") { supplements = command .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string type = supplements[1]; int weightTopping = int.Parse(supplements[2]); Topping topping = new Topping(type, weightTopping); pizza.AddTopping(topping); command = Console.ReadLine(); } pizza.CalculatePizzaCalories(); Console.WriteLine(pizza); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); return; } }
static void Main(string[] args) { // System.Globalization.CultureInfo invariantCulture = // System.Globalization.CultureInfo.InvariantCulture; var pizzaName = Console.ReadLine().Split()[1]; string[] doughArgs = Console.ReadLine().Split(); string flourType = doughArgs[1]; string bakingTechnique = doughArgs[2]; int weight = int.Parse(doughArgs[3]); try { var dough = new Dough(flourType, bakingTechnique, weight); var pizza = new Pizza(pizzaName, dough); while (true) { var line = Console.ReadLine(); if (line.ToLower() == "end") { break; } var parts = line.Split(); string toppingName = parts[1]; int toppingWeight = int.Parse(parts[2]); Topping topping = new Topping(toppingName, toppingWeight); pizza.AddTopping(topping); } Console.WriteLine($"{pizzaName} - {pizza.GetCalories():f2} Calories."); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main() { try { string[] pizzaArgs = Console.ReadLine().Split(); string pizzaName = pizzaArgs[1]; string[] doughArgs = Console.ReadLine().Split(); string flourType = doughArgs[1]; string backingTechnique = doughArgs[2]; double weight = double.Parse(doughArgs[3]); Dough dough = new Dough(flourType, backingTechnique, weight); Pizza pizza = new Pizza(pizzaName, dough); string[] toppingArgs = Console.ReadLine().Split(); while (toppingArgs[0] != "END") { string toppingType = toppingArgs[1]; double toppingWeight = double.Parse(toppingArgs[2]); Topping topping = new Topping(toppingType, toppingWeight); pizza.AddTopping(topping); toppingArgs = Console.ReadLine().Split(); } Console.WriteLine($"{pizza.Name} - {pizza.GetTotalCalories().ToString("f2")} Calories."); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } catch (InvalidOperationException ioe) { Console.WriteLine(ioe.Message); } }
private static void MakePizza(string[] param) { var pizzaName = param[1]; var numberOfToppings = int.Parse(param[2]); var pizza = new Pizza(pizzaName, numberOfToppings); var doughParam = Console.ReadLine().Split(); var dough = new Dough(doughParam[1], doughParam[2], double.Parse(doughParam[3])); pizza.Dough = dough; for (var i = 0; i < numberOfToppings; i++) { var topInfo = Console.ReadLine().Split(' '); var topping = new Topping(topInfo[1], double.Parse(topInfo[2])); pizza.AddTopping(topping); } Console.WriteLine($"{pizza.Name} - {pizza.GetPizzaCallories():f2} Calories."); }