/// <summary> /// Runs a total for the current shopping basket /// </summary> /// <param name="shoppingList">A collection of items gathered in this particular</param> /// <param name="taxationEngine">An engine to calculate tax and pricing for the items in the shopping list</param> /// <param name="transactionEngine">An engine to bill the items in the shopping list</param> private static void runBill(Dictionary<Product, int> shoppingList, PricingEngine taxationEngine, TransactionProcessingEngine transactionEngine) { foreach (KeyValuePair<Product, int> entry in shoppingList) { Product product = entry.Key; int quantity = entry.Value; bool isBaseTaxExempt = taxationEngine.isBaseTaxExempt(product.Title); bool isImportDutyTaxable = taxationEngine.isImportTaxable(product.Title); string billRecord = transactionEngine.getBillRecord(product, quantity, isBaseTaxExempt, isImportDutyTaxable); Console.WriteLine(billRecord); } Console.WriteLine("Sales Taxes: {0:F2}\nTotal: {1:F2}", transactionEngine.TaxAccumulated, transactionEngine.AmountAccumulated); }
static void Main(string[] args) { double baseTaxRate = 10d;//ideally should be entered from console and checked for sanity double importDutyRate = 5d;//ideally should be entered from console and checked for sanity PricingEngine taxationEngine = new PricingEngine(args); while (true) { TransactionProcessingEngine transactionEngine = new TransactionProcessingEngine(baseTaxRate, importDutyRate); Dictionary<Product, int> shoppingList = new Dictionary<Product, int>(); showNewTransactionMessage(); getInput(shoppingList); runBill(shoppingList, taxationEngine, transactionEngine); } }