static void Main(string[] args) { var setup = new SetUpService(); var catalog = setup.CreateCatalogue(); var scanService = new ScanService(catalog); var totalService = new TotalUpService(catalog); Console.WriteLine("Checkout service"); Console.WriteLine("Please enter the code for each item and press enter. Entering 'DONE' will return the total"); var checkOut = false; while (!checkOut) { var line = Console.ReadLine(); if (line == "DONE") { checkOut = true; Console.WriteLine("Total: " + totalService.TotalUp(scanService.ScannedItems).ToString()); Console.ReadLine(); } else { try { scanService.Scan(line); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }
public void TotalUpServiceSetUp() { var catalog = new Catalogue(); catalog.AddProduct(new Product("A13", 0.50m, "Apple")); catalog.AddProduct(new Product("C45", 1.50m, "Chicken")); catalog.AddProduct(new Product("B15", 2.50m, "Beans")); catalog.AddProduct(new Product("T23", 1.00m, "Tea")); catalog.AddOffer(new Offer("A13", 3, 1.00m)); catalog.AddOffer(new Offer("C45", 4, 4.00m)); TotalService = new TotalUpService(catalog); }