public void PastryQuantity_VerifyQuantityNullValue_Int() { Pastry newPastry = new Pastry(); newPastry.AddItems(0); Assert.AreEqual(0, newPastry.Quantity); }
public void PastryPrice_CalculatesPastryPrice_Int() { Pastry newPastry = new Pastry(); newPastry.AddItems(1); Assert.AreEqual(2, newPastry.Price); }
public void AddItems_AddThreeToQuantity_3() { Pastry newPastry = new Pastry(); newPastry.AddItems(3); Assert.AreEqual(3, newPastry.Quantity); }
public void PastryCalculator_CalculatesPastryOrders_Int() { Pastry newPastry = new Pastry(); newPastry.AddItems(9); // this AddItems method is borrowed from the parent class. It is necessary to include because it contains parameters, and gives the CalculateOrder method an argument to multiply. newPastry.CalculateOrder(); // this CalculateOrder comes from the Pastry class, and requires no parameter, but... Assert.AreEqual(17, newPastry.TotalPrice); // this assertion includes the inherited property (Item => Pastry) "TotalPrice" used in the Pastry CalculateOrder() method. }
public void CalculateOrder_CalculateTotalCostOf3Pastries_5() { Pastry newPastry = new Pastry(); newPastry.AddItems(3); newPastry.CalculateOrder(); Assert.AreEqual(5, newPastry.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(); } }