Example #1
0
        static void Main(string[] args)
        {
            Beverage espresso                = new Espresso();
            Beverage espressoWithMilk        = new Milk(espresso);
            Beverage espressoWithMilkAndWhip = new Whip(espressoWithMilk);

            Console.WriteLine($"{espressoWithMilk.GetDescription()} : {espressoWithMilk.Cost()}");
            Console.WriteLine($"{espressoWithMilkAndWhip.GetDescription()} : {espressoWithMilkAndWhip.Cost()}");
            Console.Read();
        }
Example #2
0
        static void Main(string[] args)
        {
            Coffe coffe = new Expresso();   // Recursion is the fact behind. which keeps track of the encapsulated objects.

            coffe = new Mocha(coffe);       // In this line coffe = Mocha at runtime.
            coffe = new Milk(coffe);        // In this line coffe = Milk  at runtime.
            coffe = new Mocha(coffe);       // In this line coffe = Mocha at runtime.

            Console.WriteLine("Ingredients: " + coffe.GetDescription());
            Console.WriteLine("Total Cost: " + coffe.Cost());
        }
Example #3
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();
        }
Example #4
0
        static void Main(string[] args)
        {
            Beverage coffee = new Latte();

            Console.WriteLine("Current coffee is: {0}, cost is {1}.", coffee.GetDescription(), coffee.Cost());

            Beverage latteWithMilk         = new Milk(coffee);
            Beverage latteWithMilkAndMocha = new Mocha(latteWithMilk);

            Console.WriteLine("Current coffee is: {0}, cost is {1}.", latteWithMilkAndMocha.GetDescription(), latteWithMilkAndMocha.Cost());

            Beverage latteWithMilkAndDoubleMocha = new Mocha(latteWithMilkAndMocha);

            Console.WriteLine("Current coffee is: {0}, cost is {1}.", latteWithMilkAndDoubleMocha.GetDescription(), latteWithMilkAndDoubleMocha.Cost());
        }
Example #5
0
        static void Main(string[] args)
        {
            Beverage doubleMilkEspresso = new Espresso(BeverageSize.Large);

            doubleMilkEspresso = new Milk(doubleMilkEspresso);
            doubleMilkEspresso = new Milk(doubleMilkEspresso);
            Console.WriteLine(doubleMilkEspresso.Description);
            Console.WriteLine(doubleMilkEspresso.Cost());

            Beverage milkEspresso = new Espresso(BeverageSize.Small);

            milkEspresso = new Milk(milkEspresso);
            Console.WriteLine(milkEspresso.Description);
            Console.WriteLine(milkEspresso.Cost());
        }
Example #6
0
        static void Main(string[] args)
        {
            ICoffee coffee = new Coffee();

            Console.WriteLine("Price: " + coffee.Price() + " Ingrediants: " + coffee.Ingrediants());

            coffee = new Milk(coffee);

            Console.WriteLine("Price: " + coffee.Price() + " Ingrediants: " + coffee.Ingrediants());

            coffee = new Whip(coffee);

            Console.WriteLine("Price: " + coffee.Price() + " Ingrediants: " + coffee.Ingrediants());

            Console.ReadLine();
        }
Example #7
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();
        }
        static void Main(string[] args)
        {
            IBeverage beverage = new Espresso();

            Console.WriteLine(beverage.Description + " $" + beverage.Cost());

            IBeverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine(beverage2.Description + " $" + beverage2.Cost());

            IBeverage beverage3 = new DarkRoast();

            beverage3 = new Milk(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine(beverage3.Description + " $" + beverage3.Cost());
        }
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

            beverage = new Venti(beverage);
            Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost());

            Beverage beverage5 = new Espresso();

            beverage5 = new Grande(beverage5);

            Console.WriteLine(beverage5.GetDescription() + " $" + beverage5.Cost());

            Beverage beverage2 = new DarkRoast();

            beverage2 = new Grande(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine(beverage2.GetDescription() + " $" + beverage2.Cost());

            Beverage beverage3 = new HouseBlend();

            beverage3 = new Venti(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine(beverage3.GetDescription() + " $" + beverage3.Cost());

            Beverage beverage4 = new Decaf();

            beverage4 = new Tall(beverage4);
            beverage4 = new Milk(beverage4);
            beverage4 = new Soy(beverage4);
            beverage4 = new Whip(beverage4);
            Console.WriteLine(beverage4.GetDescription() + " $" + beverage3.Cost());
        }