static void Main(string[] args) { try { string [] pizza = Console.ReadLine().Split(' '); string name = pizza[1]; int number = int.Parse(pizza[2]); var piza = new Pizza(name, number); string line = Console.ReadLine(); while (line != "END") { string[] input = line.Split(' '); string word = input[0]; switch (word) { case "Dough": string dough = input[1].ToLower(); string bakingType = input[2].ToLower(); double weight = double.Parse(input[3]); var newDought = new Dough(dough, bakingType, weight); newDought.CalcCalories(newDought); piza.Dough = newDought; piza.addDough(newDought); break; case "Topping": string toppingType = input[1]; double tweight = double.Parse(input[2]); var newTopping = new Topping(toppingType, tweight); newTopping.CalcCalories(newTopping); piza.addTopping(newTopping); break; } line = Console.ReadLine(); } var res = piza.totalCalories(); Console.WriteLine($"{piza.Name} - {res:F2} Callories"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public double CalcCalories(Dough dough) { double result = 2 * weight; switch (this.flourType) { case "wholegrain": result *= 1.0; break; case "white": result *= 1.5; break; } switch (this.bakingTecniques) { case "crispy": result *= 0.9; break; case "chewy": result *= 1.1; break; case "homemade": result *= 1.0; break; } return(result); }
public double CalcCalories(Dough dough) { double result = 2 * weight; switch (this.flourType) { case "wholegrain":result *= 1.0;break; case "white": result *= 1.5; break; } switch (this.bakingTecniques) { case "crispy": result *= 0.9;break; case "chewy": result *= 1.1; break; case "homemade": result *= 1.0; break; } return result; }
public void addDough(Dough dough) { this.dough = dough; }
public Pizza(string name, Dough dough) { Name = name; this.dough = dough; Callories = dough.Callories; }
public void IsCorrectForCorrectData() { var dough = new Dough(100, "White", "Chewy"); Assert.AreEqual(330.0, dough.Callories); }
public void AddDough(Dough dough) { doughCurrent = dough; }