public void BreadQuantity_VerifyQuantityNullValue_Int() { Bread newBread = new Bread(); newBread.AddItems(0); Assert.AreEqual(0, newBread.Quantity); }
public void BreadPrice_CalculatesBreadPrice_Int() { Bread newBread = new Bread(); newBread.AddItems(1); Assert.AreEqual(5, newBread.Price); }
public void AddItems_AddThreeToQuantity_3() { Bread newBread = new Bread(); newBread.AddItems(3); Assert.AreEqual(3, newBread.Quantity); }
public void BreadCalculator_CalculatesBreadOrders_Int() { Bread newBread = new Bread(); newBread.AddItems(20); newBread.CalculateOrder(); Assert.AreEqual(95, newBread.TotalPrice); }
public void CalculateOrder_CalculateTotalCostOf3Breads_15() { Bread newBread = new Bread(); newBread.AddItems(3); newBread.CalculateOrder(); Assert.AreEqual(15, newBread.TotalCost); }
public static void Main() { Console.WriteLine("Welcome to Pierre's Boulangerie!"); Console.WriteLine("We have two items for sale,"); Console.WriteLine("Bread or Pastries"); Console.WriteLine("Bread is $5 for a loaf; buy two, get one free."); Console.WriteLine("Pastries are $2 each, or 3 for $5."); Console.WriteLine("Would you like some bread? (yes or no)"); string breadBuy = Console.ReadLine().ToLower(); if (breadBuy == "yes") { Console.WriteLine("How many loaves of bread can I get for you today?"); string breadOrder = Console.ReadLine().ToLower(); Bread newBread = new Bread(); newBread.AddItems(int.Parse(breadOrder)); newBread.CalculateOrder(); Console.WriteLine("Your bread order comes to: $" + newBread.TotalPrice); Console.WriteLine("Would you like some pastries? (yes or no)"); string pastryBuy = Console.ReadLine().ToLower(); if (pastryBuy == "yes") { Console.WriteLine("How many pastries would you like?"); string pastryOrder = Console.ReadLine().ToLower(); Pastry newPastry = new Pastry(); newPastry.AddItems(int.Parse(pastryOrder)); newPastry.CalculateOrder(); Console.WriteLine("Your pastry order comes to: $" + newPastry.TotalPrice); Console.WriteLine("Would you care for anything else (yes or no)"); string finalAnswer = Console.ReadLine().ToLower(); if (finalAnswer == "yes") { Main(); } else { int grandTotal = newPastry.TotalPrice + newBread.TotalPrice; Console.WriteLine("Thanks, for coming in today."); Console.WriteLine("Your grand total comes to: $" + grandTotal); } } } else { Console.WriteLine("Thanks for coming to smell the fresh-baked bread. Have a nice day."); } }
// Prompts user how many of the item they wish to buy. Validates user input until integer. public static void BuyItem(string item) { Console.Clear(); bool result = false; int quantityToPurchase = 0; while (!result) { RollingConsoleWrite($"Please enter the amount of {item} you would like to buy?\n(Only purchase the amount of {item} you want to pay for. We will add the free {item}(s) when you complete your order.)\n"); string userString = Console.ReadLine(); result = int.TryParse(userString, out quantityToPurchase); } if (item == "pastry") { pastries.AddItems(quantityToPurchase); BuyMore(); } else if (item == "bread") { bread.AddItems(quantityToPurchase); BuyMore(); } }