public void DisplayCart() { double price = CalculatePrice(); Table.PrintAlign("------------------"); Table.PrintAlign("CART"); Table.PrintAlign("------------------"); Table.PrintLine(); if (Items.Count == 0) { Table.PrintAlign("Empty Cart"); Table.PrintAlign("------------------"); } else { Table.PrintRowWithIdCount(new string [] { "Id", "Product", "Cost", "Count" }); Table.PrintLine(); foreach (KeyValuePair <BakeryItem, int> kvp in CountDict) { BakeryItem item = kvp.Key; string [] result = item.Display(); string [] count = new string[] { kvp.Value.ToString() }; string [] combined = new string[result.Length + count.Length]; Array.Copy(result, combined, result.Length); Array.Copy(count, 0, combined, result.Length, count.Length); Table.PrintRowWithIdCount(combined); Table.PrintLine(); } } if (Offer1 || Offer2) { Table.PrintAlign("Applied offers:"); if (Offer1) { Table.PrintAlign("Bread. Buy any 2, get 1 free."); } if (Offer2) { Table.PrintAlign("Pastry. Buy any 3 for $8."); } Table.PrintAlign("------------------"); } Table.PrintAlign($"Total Cost: ${String.Format("{0:0.00}", price)}"); Table.PrintLine(); }
public void PrintMenu() { Table.PrintAlign("------------------"); Table.PrintAlign("MENU"); Table.PrintAlign("------------------"); Console.WriteLine(); Table.PrintAlign("------------------"); Table.PrintAlign("BREADS"); Table.PrintAlign("------------------"); Table.PrintLine(); Table.PrintRowWithId(new string [] { "Id", "Name", "Price" }); Table.PrintLine(); for (int i = 0; i < 6; i++) { BakeryItem bread = Items[i]; Table.PrintRowWithId(bread.Display()); Table.PrintLine(); } Table.PrintAlign("------------------"); Table.PrintAlign("PASTRIES"); Table.PrintAlign("------------------"); Table.PrintLine(); Table.PrintRowWithId(new string [] { "Id", "Name", "Price" }); Table.PrintLine(); for (int i = 6; i < 12; i++) { BakeryItem pastry = Items[i]; Table.PrintRowWithId(pastry.Display()); Table.PrintLine(); } Table.PrintAlign("------------------"); Table.PrintAlign("OFFERS"); Table.PrintAlign("------------------"); Table.PrintLine(); Table.PrintRow(new string [] { "Product", "Offer" }); Table.PrintLine(); Table.PrintRow(new string [] { "Bread", "Buy any 2, get 1 free" }); Table.PrintLine(); Table.PrintRow(new string [] { "Pastry", "Buy any 3 for $8" }); Table.PrintLine(); }