private static void printToConsole(ShoppingBasket shoppingBasket) { Console.WriteLine("\nReceipt "); foreach (GroceryItemData item in shoppingBasket.getShoppingBasket()) { int amount = item.Count; while (amount > 0) { if (item.isOnPromotion && item.PromotionInfo.isMetPromoRequirements(amount)) { IPromotion promoInfo = item.PromotionInfo; displayPromoInfoToConsole(item, promoInfo); amount -= promoInfo.getQuantityToGetPromoPrice(); } else if (amount > 1) { displayMultipleRegularPricedItem(item); amount -= item.Count; } else { Console.WriteLine(item.Name + "\t" + MoneyDisplayUtil.formatMoneyDisplay(item.RegularPrice)); amount -= 1; } } } Console.WriteLine("--------------------------"); Console.WriteLine("Total Savings = " + MoneyDisplayUtil.formatMoneyDisplay(shoppingBasket.calculateTotalSavings())); Console.WriteLine("Total Due = " + MoneyDisplayUtil.formatMoneyDisplay(shoppingBasket.calculateFinalBill())); }
public string getPromoDisplayInfo() { if (_quantityToGetPromoPrice > 1) { return(string.Format("Reduce price \n\tbuy {0} for {1} \n\tregular {2} each", _quantityToGetPromoPrice, MoneyDisplayUtil.formatMoneyDisplay(_totalSalePriceForQuantityMet), MoneyDisplayUtil.formatMoneyDisplay(_regularPrice))); } return(string.Format("Reduce price \n\twas @ {0}", MoneyDisplayUtil.formatMoneyDisplay(_regularPrice))); }
private static void displayPromoInfoToConsole(GroceryItemData item, IPromotion promoInfo) { if (promoInfo.getQuantityToGetPromoPrice() == 1) { Console.WriteLine(item.Name + " \t" + MoneyDisplayUtil.formatMoneyDisplay(promoInfo.getTotalPriceForQuantityMet())); } else { Console.WriteLine(item.Name + " (X" + promoInfo.getQuantityToGetPromoPrice() + ") " + MoneyDisplayUtil.formatMoneyDisplay(promoInfo.getTotalPriceForQuantityMet())); } Console.WriteLine("\t" + item.PromotionInfo.getPromoDisplayInfo()); Console.WriteLine("\tsavings " + MoneyDisplayUtil.formatMoneyDisplay(item.PromotionInfo.getSavings())); }
private static void displayMultipleRegularPricedItem(GroceryItemData item) { Console.WriteLine(item.Name + " (X" + item.Count + ") " + MoneyDisplayUtil.formatMoneyDisplay(item.RegularPrice * item.Count)); Console.WriteLine("\t @ " + MoneyDisplayUtil.formatMoneyDisplay(item.RegularPrice) + " each"); }