public static void Main() { string pizzaName = Console.ReadLine().Split()[1]; Pizza pizza = null; try { pizza = new Pizza(pizzaName); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); Environment.Exit(0); } string[] doughParams = Console.ReadLine().Split(); Dough dough = GetDough(doughParams); pizza.Dough = dough; string input = null; while ((input = Console.ReadLine()) != "END") { string[] toppingParams = input.Split(); string toppingType = toppingParams[1]; int toppingWeightInGrams = int.Parse(toppingParams[2]); Topping topping = null; try { topping = new Topping(toppingType, toppingWeightInGrams); pizza.AddTopping(topping); } catch (Exception ex) { Console.WriteLine(ex.Message); Environment.Exit(0); } } Console.WriteLine(pizza); }
static void Main() { string pizzaName = Console.ReadLine().Split()[1]; // Read doughInfo string[] doughInfo = Console.ReadLine().Split(); string flourType = doughInfo[1]; string bakingTechnique = doughInfo[2]; double weight = double.Parse(doughInfo[3]); Dough dough; Pizza pizza; try { dough = new Dough(flourType, bakingTechnique, weight); pizza = new Pizza(pizzaName, dough); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); return; } while (true) { string[] toppingInfo = Console.ReadLine().Split(); if (toppingInfo[0] == "END") { break; } string toppingType = toppingInfo[1]; double toppingWeight = double.Parse(toppingInfo[2]); try { Topping topping = new Topping(toppingType, toppingWeight); pizza.Addtopping(topping); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); return; } } Console.WriteLine($"{pizzaName} - {pizza.CalculateTotalCalories():f2} Calories."); }
public void Run() { try { string[] pizzaInfo = Console.ReadLine() .Split(" "); string pizzaName = pizzaInfo[1]; Pizza pizza = new Pizza(pizzaName); string[] doughInfo = Console.ReadLine() .Split(" "); string typeDough = doughInfo[1]; string typeBakingTechnique = doughInfo[2]; int doughWeight = int.Parse(doughInfo[3]); Dough dough = new Dough(typeDough, typeBakingTechnique, doughWeight); pizza.Dough = dough; string toppings = Console.ReadLine(); while (toppings != "END") { string[] toppingInfo = toppings .Split(" "); string typeTopping = toppingInfo[1]; int toppingWeight = int.Parse(toppingInfo[2]); Topping topping = new Topping(typeTopping, toppingWeight); pizza.AddTopping(topping); toppings = Console.ReadLine(); } Console.WriteLine(pizza); } catch (ArgumentException argEx) { Console.WriteLine(argEx.Message); } }
private static void MakePizza(string[] tokens) { var doughInf = Console.ReadLine().Split(); var dough = new Dough(doughInf[1], doughInf[2], double.Parse(doughInf[3])); var pizza = new Pizza(tokens[1], dough, int.Parse(tokens[2])); var numbToppings = int.Parse(tokens[2]); for (int i = 0; i < numbToppings; i++) { var topInf = Console.ReadLine().Split(); var top = new Topping(topInf[1], double.Parse(topInf[2])); } Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():f2} Calories."); }
static void Main(string[] args) { // Pizza Meatless //Dough Wholegrain Crispy 100 //Topping Veggies 50 //Topping Cheese 50 //END Pizza pizza; Dough dough; try { string[] pizzaInfo = Console.ReadLine().Split(); string pizzaName = pizzaInfo[1]; pizza = new Pizza(pizzaName); string[] doughInfo = Console.ReadLine().Split(); string flour = doughInfo[1]; string bakingTech = doughInfo[2]; double weight = double.Parse(doughInfo[3]); dough = new Dough(flour.ToLower(), bakingTech.ToLower(), weight); pizza.PizzaDough = dough; string toppingInfo; while ((toppingInfo = Console.ReadLine()) != "END") { string[] toppingParams = toppingInfo.Split(); string toppingName = toppingParams[1].ToLower(); double toppingWeight = double.Parse(toppingParams[2]); Topping topping = new Topping(toppingName, toppingWeight); pizza.Add(topping); } Console.WriteLine($"{pizza.Name} - {pizza.PizzaCalories():f2} Calories."); } catch (Exception e) { Console.WriteLine(e.Message); return; } }
public Pizza(string name, Dough dough) { if ((dough.bakingTechnique.ToLower() == "crispy" || dough.bakingTechnique.ToLower() == "chewy" || dough.bakingTechnique.ToLower() == "homemade") && (dough.flourType.ToLower() == "white" || dough.flourType.ToLower() == "wholegrain") && (dough.weight >= 1 && dough.weight <= 200)) { if (name.Length < 1 || name.Length > 15) { Console.WriteLine("Pizza name should be between 1 and 15 symbols."); } else { this.name = name; this.dough = dough; } } }
public static void Main() { try { var pizzaInput = Console.ReadLine().Split(); var pizza = new Pizza(pizzaInput[1]); var doughInput = Console.ReadLine().Split(); var dough = new Dough(doughInput[1], doughInput[2], double.Parse(doughInput[3])); pizza.Dough = dough; MakePizza(pizza); } catch (Exception e) { Console.WriteLine(e.Message); return; } }
public override void Prepare() { Pepperoni = ingredientFactory.CreatePepperoni(); Dough = ingredientFactory.CreateDough(); Sauce = ingredientFactory.CreateSause(); Veggies = ingredientFactory.CreateVeggies(); Console.WriteLine($"Preparing {Name}"); Console.WriteLine(Pepperoni.GetType().ToString()); Console.WriteLine(Dough.GetType().ToString()); Console.WriteLine(Sauce.GetType().ToString()); foreach (var item in Veggies) { Console.WriteLine(item.GetType().ToString()); } }
public void OneFoodToStringTest() { Order order = Order.getInstance(); order.ResetCondiments(); Food dough = new Dough(); dough.Id = 0; dough.Name = "Normal dough"; dough.Description = "This is a regular dough where we add all the ingridients what is needed to a good pizza dough"; dough.Price = 1.99; order.Add(dough); string actual = order.ToString(); string expected = "0/1,99/Normal dough/This is a regular dough where we add all the ingridients what is needed to a good pizza dough;"; Assert.AreEqual(expected, actual); }
public override string ToString() { var result = new StringBuilder(); result.AppendLine("---- " + Name + " ----"); if (Dough != null) { result.AppendLine(Dough.ToString()); } if (Sauce != null) { result.AppendLine(Sauce.ToString()); } if (Cheese != null) { result.AppendLine(Cheese.ToString()); } if (Veggies != null) { bool isFirst = true; foreach (var veggy in Veggies) { if (isFirst) { result.Append(veggy.ToString()); isFirst = false; } else { result.Append(", "); result.Append(veggy.ToString()); } } result.AppendLine(); } if (Pepperoni != null) { result.AppendLine(Pepperoni.ToString()); } if (Clams != null) { result.AppendLine(Clams.ToString()); } return(result.ToString()); }
public void Run() { try { string[] pizzaInput = reader .ConsoleReadLine() .Split(" "); string[] doughInput = reader .ConsoleReadLine() .Split(" "); string pizzaName = pizzaInput[1]; string flour = doughInput[1]; string baking = doughInput[2]; double weightInGrams = double.Parse(doughInput[3]); Dough dough = new Dough(flour, baking, weightInGrams); Pizza pizza = new Pizza(pizzaName, dough); string input = reader.ConsoleReadLine(); while (input.Equals("END") == false) { string[] toppingArgs = input .Split(" "); string type = toppingArgs[1]; double weight = double.Parse(toppingArgs[2]); Topping topping = new Topping(type, weight); pizza.AddTopping(topping); input = reader.ConsoleReadLine(); } writer.ConsoleWriteLine(pizza.ToString()); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } }
static void Main(string[] args) { Pizza pizza = new Pizza(); Dough dough; string pizzasName = "N"; string input; try { while ((input = Console.ReadLine()) != "END") { var tokens = input.Split(); string name = tokens[0]; switch (name) { case "Pizza": string nameInput = tokens[1]; pizzasName = nameInput; break; case "Dough": string flaur = tokens[1]; string bakingTechnique = tokens[2]; double grams = double.Parse(tokens[3]); dough = new Dough(flaur, bakingTechnique, grams); pizza = new Pizza(pizzasName, dough); break; case "Topping": string type = tokens[1]; double weight = double.Parse(tokens[2]); Topping topping = new Topping(type, weight); pizza.AddTopping(topping); break; } } Console.WriteLine(pizza.ToString()); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } }
public void Run() { try { Pizza pizza = CreatePizza(); Dough dough = CreateDough(); pizza.Dough = dough; AddToppingsToPizza(pizza); Console.WriteLine(pizza); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } }
public ISet <Dough> GetAllDoughsFromDb() { ISet <Dough> doughs = new HashSet <Dough>(); int id = 0; while (true) { id++; Dough dough = this.GetDoughFromDb(id); if (dough.Id == 0) { break; } doughs.Add(dough); } return(doughs); }
public void AddFoodTestWithNegativPrice() { Order order = Order.getInstance(); Food dough = new Dough(); dough.Price = -1.0; Exception exception = null; try { bool result = order.Add(dough); } catch (NegativePriceException e) { exception = e; } Assert.AreNotEqual(exception, null); }
static void Main(string[] args) { Oven oven = new Oven((OvenType)0); List <Ingridient> ingridients = new List <Ingridient>() { new Ingridient("Tomatoes"), new Ingridient("Ham"), new Ingridient("Cheese") }; IngridientList ingridientList = new IngridientList(ingridients); Dough dough = new Dough((DoughType)1); Pizza Pizza = new Pizza(oven, dough, ingridientList); Console.WriteLine(Pizza); }
public static void MakePizza(string[] tokens) { var numberToppings = int.Parse(tokens[2]); var pizza = new Pizza(tokens[1], numberToppings); var doughInfo = Console.ReadLine().Split(' '); var dough = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3])); pizza.Dough = dough; for (var i = 0; i < numberToppings; i++) { var topInfo = Console.ReadLine().Split(' '); var topping = new Topping(topInfo[1], double.Parse(topInfo[2])); pizza.AddTopping(topping); } Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():f2} Calories."); }
private static Pizza CreatePizzaWithDough() { Pizza pizza = new Pizza(); string[] nameOfPizza = Console.ReadLine() .Split(" ") .ToArray(); pizza.Name = nameOfPizza[1]; string[] infoForDough = Console.ReadLine() .Split(" ") .ToArray(); Dough dough = new Dough(infoForDough[1], infoForDough[2], double.Parse(infoForDough[3])); pizza.Dough = dough; return(pizza); }
private static string AddIngredients(Pizza pizza, string[] line, string pizzaName) { if (line[0] == "Pizza") { pizzaName = line[1]; try { pizza.Name = pizzaName; } catch (Exception e) { Console.WriteLine(e.Message); Environment.Exit(0); } } else if (line[0] == "Dough") { try { Dough dough = new Dough(line[1], line[2], double.Parse(line[3])); pizza.Dough = dough; } catch (Exception e) { Console.WriteLine(e.Message); Environment.Exit(0); } } else if (line[0] == "Topping") { try { Topping topping = new Topping(line[1], double.Parse(line[2])); pizza.AddTopping(topping); } catch (Exception e) { Console.WriteLine(e.Message); Environment.Exit(0); } } return pizzaName; }
public void AddFoodTestWithoutDescription() { Order order = Order.getInstance(); Food dough = new Dough(); dough.Description = ""; Exception exception = null; try { bool result = order.Add(dough); } catch (NoDescriptionException e) { exception = e; } Assert.AreNotEqual(exception, null); }
static void Main() { try { var name = Console.ReadLine().Split()[1]; Dough dough = ReadDough(); Pizza pizza = new Pizza(name, dough); ReadToppings(pizza); Console.WriteLine(pizza); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } }
public void Run() { var pizzaInfo = Console.ReadLine().Split(); Pizza pizza = new Pizza(pizzaInfo[1]); var doughInfo = Console.ReadLine().Split(); Dough dough = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3])); pizza.Dough = dough; string toppings; while ((toppings = Console.ReadLine()) != "END") { var toppingsInfo = toppings.Split(); Topping topping = new Topping(toppingsInfo[1], double.Parse(toppingsInfo[2])); pizza.Add(topping); } Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:f2} Calories."); }
public static void MakePizza(string[] inParams) { int numberToppings = int.Parse(inParams[2]); Pizza pizza = new Pizza(inParams[1], numberToppings); string[] doughInfo = Console.ReadLine().Split(' '); Dough dough = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3])); pizza.Dough = dough; for (var i = 0; i < numberToppings; i++) { string[] toppingInfo = Console.ReadLine().Split(' '); Topping topping = new Topping(toppingInfo[1], double.Parse(toppingInfo[2])); pizza.AddTopping(topping); } Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories():f2} Calories."); }
public void Run() { try { var pizzaName = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries) .Skip(1) .First(); Dough dough = DoughFactory(); List <Topping> listToping = ToppingListFactory(); Pizza pizza = new Pizza(pizzaName, dough, listToping); Console.WriteLine(pizza.ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void AllGreenPizzasIncreaseMixTimeByThreeMinutes() { Dough[] doughs = new Dough[] { new ThinDough(), new PanDough(), new HandTossedDough() }; foreach (Dough dough in doughs) { int originalMixTime = dough.MixTime; dough.ColorGreen(); int newMixTime = dough.MixTime; Assert.That(newMixTime, Is.EqualTo(originalMixTime + 3)); } }
public static void Main() { try { string input = Console.ReadLine(); Dough dough = null; Topping currentTopping = null; Pizza pizza = new Pizza(); while (input != "END") { string[] args = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (args[0].ToLower() == "pizza") { if (args.Length < 2) { throw new ArgumentException("Pizza name should be between 1 and 15 symbols."); } pizza.Name = args[1]; } else if (args[0].ToLower() == "dough") { dough = new Dough(args[1], args[2], double.Parse(args[3])); pizza.Dough = dough; } else { currentTopping = new Topping(args[1], double.Parse(args[2])); pizza.AddTopping(currentTopping); } input = Console.ReadLine(); } Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:0.00} Calories."); } catch (Exception e) { Console.WriteLine(e.Message); } }
/// <summary> /// Gives back type of food. Type can be dough,sauce,meat,topping,cheese. /// </summary> /// <param name="type"></param> /// <returns></returns> public Food GetFood(string type) { Food temp = new Dough(); if (type == null) { throw new NullReferenceException(); } else if (type.Length > 10 || type.Length < 4) { throw new InvalidLegthExceptionForFood(); } else { switch (type) { case "dough": break; case "sauce": temp = new Sauce(); break; case "meat": temp = new Meat(); break; case "topping": temp = new Topping(); break; case "cheese": temp = new Cheese(); break; default: break; } } return(temp); }
public void Run() { try { string[] pizzaInfo = Console.ReadLine().Split(); string pizzaName = pizzaInfo[1]; string[] doughInfo = Console.ReadLine().Split(); string flourType = doughInfo[1].ToLower(); string bakingTechnique = doughInfo[2].ToLower(); int doughGrams = int.Parse(doughInfo[3]); Dough dough = new Dough(flourType, bakingTechnique, doughGrams); Pizza pizza = new Pizza(pizzaName, dough); string command = Console.ReadLine(); while (command != "END") { string[] toppingInfo = command.Split(); string toppingName = toppingInfo[1]; int toppingGrams = int.Parse(toppingInfo[2]); Topping topping = new Topping(toppingName, toppingGrams); pizza.AddTopping(topping); command = Console.ReadLine(); } Console.WriteLine(pizza); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } catch (InvalidOperationException ioe) { Console.WriteLine(ioe.Message); } }
static void Main() { try { string[] pizzaTokens = Console.ReadLine().Split(' ', StringSplitOptions.None); string pizzaName = pizzaTokens[1]; Pizza pizza = new Pizza(pizzaName); string[] doughTokens = Console.ReadLine().Split(' ', StringSplitOptions.None); string flourType = doughTokens[1]; string bakingTechnique = doughTokens[2]; int doughWeight = int.Parse(doughTokens[3]); Dough dough = new Dough(flourType, bakingTechnique, doughWeight); pizza.Dough = dough; string input = Console.ReadLine(); while (input != "END") { string[] toppingTokens = input.Split(' ', StringSplitOptions.None); string type = toppingTokens[1]; int toppingWeight = int.Parse(toppingTokens[2]); Topping topping = new Topping(type, toppingWeight); input = Console.ReadLine(); pizza.AddTopping(topping); } Console.WriteLine(pizza); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } }
private static void MakePizza(string[] tokens) { var pizza = new Pizza(tokens[1]); var doughInfo = Console.ReadLine().Split(); var dough = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3])); pizza.Dough = dough; string toppings; while ((toppings = Console.ReadLine()) != "END") { var toppingInfo = toppings.Split(); var topping = new Topping(toppingInfo[1], double.Parse(toppingInfo[2])); pizza.AddTopping(topping); } Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():F2} Calories."); }
public void Should_not_be_able_to_create_models_with_ArbitraryObject_fields_N_levels_deep_with_an_empty_object_value(int n) { using (var server = TestServer.Create<TestStartup>()) { // arrange var schema = new MetaType { Name = "simple_schema" }; var i = 0; var fields = schema.Fields; while (i < n) { var obj = new ArbitraryObjectField { Name = "obj{0}".FormatString(i) }; fields.Add(obj); fields = obj.Fields; i++; } using (var session = Storage.GetAsyncSession()) { session.StoreAsync(schema).Wait(); session.SaveChangesAsync().Wait(); } // act i = 0; var model = new Model { }; var o = model as Dough; while (i < n) { var fieldName = "obj{0}".FormatString(i); o[fieldName] = new Dough { }; o = o[fieldName] as Dough; i++; } var json = JsonConvert.SerializeObject(model, this.JsonConverter); var response = server.CreateRequest("api/models/{0}".FormatString(schema.Name)) .And(message => message.Content = new StringContent(json, Encoding.UTF8, "application/json")) .PostAsync() .Result; // verify Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); var content = response.Content.ReadAsStringAsync().Result; var result = JsonConvert.DeserializeObject<ApiError>(content); Assert.Equal(ApiErrorCode.SchemaMismatch, result.ErrorCode); } }
public void Cook(Dough dough) { Dough = dough; }
private object ReadObject(JsonReader reader) { var obj = new Dough(); while (reader.Read()) { switch (reader.TokenType) { case JsonToken.PropertyName: var propertyName = reader.Value.ToString(); if (!reader.Read()) { throw new JsonSerializationException("Unexpected end when reading Model object"); } var v = this.ReadValue(reader); obj[propertyName] = v; break; case JsonToken.Comment: break; case JsonToken.EndObject: return obj; } } throw new JsonSerializationException("Unexpected end when reading Model object"); }