예제 #1
0
        static void Main(string[] args)
        {
            Beverage beverage = new DarkTea();

            beverage = new Sugar(beverage);
            beverage = new Milk(beverage);
            beverage = new Discount(beverage);

            Console.WriteLine(beverage.Cost());
            Console.WriteLine(beverage.GetDescription());
            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Client client = new Client();

            Coffee coffee = new Coffee();

            Console.WriteLine("Client: I get a simple drink:");
            client.ClientCode(coffee);
            Console.WriteLine();

            Milk  milk  = new Milk(coffee);
            Sugar sugar = new Sugar(milk);

            Console.WriteLine("Client: Now I've got a decorated drink:");
            client.ClientCode(sugar);

            Console.ReadLine();
        }
예제 #3
0
        static void Main()
        {
            Console.WriteLine("Observer pattern \r\n");

            Console.WriteLine("I order a DarkRoast");
            Beverage beverage1 = new DarkRoast();

            TicketUpdate(beverage1);

            Console.WriteLine("I want a double sugar");
            beverage1 = new Sugar(beverage1);
            beverage1 = new Sugar(beverage1);
            TicketUpdate(beverage1);

            Console.WriteLine("And also some booze in it");
            beverage1 = new Whiskey(beverage1);
            TicketUpdate(beverage1);

            Console.ReadLine();
        }