static void Main(string[] args) { try { #region Bootstrap IConfigurationRoot configuration = GetConfigurationRoot(); var configurationHelper = new ConfigurationHelper(configuration); TaxSettings taxSettings = configurationHelper.GetTaxSettings(); IList <Tax> taxes = taxSettings.GetAllTaxes(); var taxCalculator = new TaxCalculator(taxes); IDictionary <string, CategoryType> productCategories = configurationHelper.GetProductCategories(); var shoppingBasketCreator = new ShoppingBasketCreator(); var receiptDetailCreator = new ReceiptDetailCreator(); var receiptDeatilPrinter = new ReceiptDeatilPrinter(); #endregion string[] inputLines = GetInputLines(configuration); ShoppingBasket shoppingBasket = shoppingBasketCreator.CreateShoppingBasket(inputLines, productCategories); IList <TaxedProduct> taxedProducts = taxCalculator.ApplyTaxes(shoppingBasket); ReceiptDetail receiptDetail = receiptDetailCreator.CreateReceiptDetail(taxedProducts); receiptDeatilPrinter.Print(receiptDetail); } catch (Exception e) { Console.WriteLine(e); Console.ReadLine(); } }
public void Initialize() { _shoppingBasketCreator = new ShoppingBasketCreator(); _productCategories = new Dictionary <string, CategoryType>() { { "book", CategoryType.Books }, { "box of chocolates", CategoryType.Foods }, { "chocolate bar", CategoryType.Foods }, { "packet of headache pills", CategoryType.MedicalProducts }, }; IList <Tax> taxes = new List <Tax>() { new FlatTax() { Description = "Basic Sales Tax", ExcludedCategories = new HashSet <CategoryType>() { CategoryType.Books, CategoryType.Foods, CategoryType.MedicalProducts }, Rate = 0.1m }, new ImportedTax() { Description = "Import duty", Rate = 0.05m } }; _taxCalculator = new TaxCalculator(taxes); _receiptDetailCreator = new ReceiptDetailCreator(); }
public void Initialize() { _shoppingBasketCreator = new ShoppingBasketCreator(); }