static void Main() { var repository = new CustomerRepository(); var freePurchaseVisitor = new FreePurchaseVisitor(); var discountRaseVisitor = new DiscountRaseVisitor(); var premiumCustomers = repository.GetPremiumCustomers(); foreach (var premiumCustomer in premiumCustomers) { premiumCustomer.AcceptVisitor(discountRaseVisitor); } var allCustomers = repository.GetAll(); foreach (var customer in allCustomers) { customer.AcceptVisitor(freePurchaseVisitor); } foreach (var customer in allCustomers) { Console.WriteLine(customer); } }
static void Main() { var repository = new CustomerRepository(); var visitorDiscount = new DiscountRaiseVisitor(); var visitorFreeItem = new FreePurchaseVisitor(); var premiumCustomers = repository.GetPremiumCustomers(); foreach (var premiumCustomer in premiumCustomers) { premiumCustomer.Accept(visitorDiscount); } var allCustomers = repository.GetAll(); foreach (var customer in allCustomers) { customer.Accept(visitorFreeItem); } }
public static void Main() { var repository = new CustomerRepository(); var discountVisitor = new DiscountRaiseVisitor(); var freePurchaseVisitor = new FreePurchaseVisitor(); var premiumCustomers = repository.GetPremiumCustomers(); foreach (var premiumCustomer in premiumCustomers) { premiumCustomer.Accept(discountVisitor); } var allCustomers = repository.GetAll(); foreach (var customer in allCustomers) { customer.Accept(freePurchaseVisitor); } }