static void AddDiscounts(IntelligentStoreWithDiscount store) { //Если раньше Mary не могла купить oven, то после скидки - может //работает с любой из строчек // store.DiscountSystem.SetDiscount(store.ListOfProducts.ElementAt(3),90); store.DiscountSystem.SetDiscount(ProductsType.Oven, 90); }
static void Main(string[] args) { List <Buyer> buyers = FillBuyerList(); IntelligentStoreWithDiscount store = new IntelligentStoreWithDiscount(FillProductsList(), new IntelligentSystem(), new DiscountSystem()); AddDiscounts(store); OutputCanToBuyProducts(buyers, store); Console.ReadKey(); }
static void OutputCanToBuyProducts(List <Buyer> buyers, IntelligentStoreWithDiscount store) { foreach (Buyer b in buyers) { List <Product> canBuyList = store.IntelligentSystem.CanToBuy(b, store.DiscountSystem.CanToBuyWithDiscount(store.ListOfProducts)); Console.Write(b.FirstName + " can buy "); foreach (var p in canBuyList) { DiscountProduct dp = p as DiscountProduct; if (dp != null) { Console.Write(dp.ProductName + " with discount " + dp.DiscountProcent + "%, "); } else { Console.Write(p.ProductName + ", "); } } Console.WriteLine(); } }