Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

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

            Beverage beverage2 = new DarkRoast();

            beverage2.SetSize(Beverage.Size.VENTI);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);

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

            Beverage beverage3 = new DarkRoast();

            beverage3.SetSize(Beverage.Size.GRANDE);
            beverage3 = new Soy(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);

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

            Console.ReadLine();
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     Beverage beverage = new DarkRoast();
     beverage = new MilkShot(beverage);
     beverage = new Mocha(beverage);
     Console.WriteLine(string.Format("{0}: {1}", beverage.GetDescription(), beverage.GetCost()));
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            /*
             * Design principle: Classes should be open for extension, but closed for modification.
             *
             * The Decorator Pattern: attaches additional responsabilities to an object dynamically.
             * Decorators provide a flexible alternative to subclassing for extending functionality.
             */

            Beverage beverage = new Expresso();

            Console.WriteLine($"{beverage.GetDescription()} ${beverage.Cost()}");

            Beverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine($"{beverage2.GetDescription()} ${beverage2.Cost()}");

            Beverage beverage3 = new HouseBlend();

            beverage3 = new Soy(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine($"{beverage3.GetDescription()} ${beverage3.Cost()}");

            Console.ReadKey();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

            Console.WriteLine(beverage.getDescription()
                              + " $" + beverage.cost());

            Beverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine(beverage2.getDescription()
                              + " $" + beverage2.cost());

            Beverage beverage3 = new HouseBlend();

            beverage3 = new Soy(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine(beverage3.getDescription()
                              + " $" + beverage3.cost());

            Console.ReadKey();
        }
Ejemplo n.º 5
0
        private static void Coffee()
        {
            Beverage beverage = new Espresso();

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

            Beverage beverage2 = new HouseBlend();

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

            Beverage beverage3 = new DarkRoast();

            beverage3 = new Mocha(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine(beverage3.GetDescription() + " $" + beverage3.Cost());
            beverage3 = new Grande(beverage3);
            Console.WriteLine(beverage3.GetDescription() + " $" + beverage3.Cost());
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            Beverage beverage = new DarkRoast();

            beverage = new MilkShot(beverage);
            beverage = new Mocha(beverage);
            Console.WriteLine(string.Format("{0}: {1}", beverage.GetDescription(), beverage.GetCost()));
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Beverage beverage = new DarkRoast();

            beverage = new SoyDecorator(beverage);
            Console.WriteLine(beverage.GetDescription());
            beverage = new SoyDecorator(beverage);
            beverage = new MilkDecorator(beverage);
            Console.WriteLine($"Name: {beverage.GetDescription()}  Price: {beverage.GetPrice()}");
        }
Ejemplo n.º 8
0
        static void Main()
        {
            Beverage beverage = new DarkRoast();

            beverage = new Mocha(beverage);
            beverage = new Soy(beverage);
            beverage = new Grande(beverage);
            Console.WriteLine(beverage.GetDescription());
            Console.WriteLine("Total: $" + beverage.Cost());
            Console.ReadKey();
        }
        public void TestOrderDarkRoastWithMochaWhip()
        {
            Beverage beverage = new DarkRoast();

            beverage = new Mocha(beverage);
            beverage = new Mocha(beverage);
            beverage = new Whip(beverage);

            string test = $"{beverage.GetDescription()} ${beverage.Cost().ToString("0.00")}";

            Assert.AreEqual(test, "Dark Roast, Mocha, Mocha, Whip $2.54");
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            IBeverage beverage = new Espresso();

            Console.WriteLine(beverage.getDescription() + " $" + beverage.cost());

            IBeverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);

            Console.WriteLine(beverage2.getDescription() + " $" + beverage2.cost());
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

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

            Beverage beverage2 = new DarkRoast();

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

            Console.ReadKey();
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            Beverage       darkRoast          = new DarkRoast();
            MochaDecorator darkRoastMocha     = new MochaDecorator(darkRoast);
            WhipDecorator  darkRoastMochaWhip = new WhipDecorator(darkRoastMocha);

            Console.WriteLine("Beverage = {0}. Cost = {1}", darkRoastMochaWhip.GetDescription(), darkRoastMochaWhip.GetCost());

            Beverage       houseBlend                   = new HouseBlend();
            MochaDecorator houseBlendMocha              = new MochaDecorator(houseBlend);
            MochaDecorator houseBlendDoubleMocha        = new MochaDecorator(houseBlendMocha);
            SoyDecorator   houseBlendDoubleMochaSoy     = new SoyDecorator(houseBlendDoubleMocha);
            WhipDecorator  houseBlendDoubleMochaSoyWhip = new WhipDecorator(houseBlendDoubleMochaSoy);

            Console.WriteLine("Beverage = {0}. Cost = {1}", houseBlendDoubleMochaSoyWhip.GetDescription(), houseBlendDoubleMochaSoyWhip.GetCost());

            Console.ReadLine();
        }
Ejemplo n.º 13
0
        static void Main()
        {
            Beverage beverage = new Espresso();

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

            Beverage beverage2 = new DarkRoast();

            beverage2 = new MochaCondiment(beverage2);
            beverage2 = new MochaCondiment(beverage2);
            beverage2 = new WhipCondiment(beverage2);
            Console.WriteLine(beverage2.Description + " $" + beverage2.Cost());

            Beverage beverage3 = new HouseBlend();

            beverage3 = new MochaCondiment(beverage3);
            beverage3 = new WhipCondiment(beverage3);
            Console.WriteLine(beverage3.Description + " $" + beverage3.Cost());
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

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

            Beverage darkRoast = new DarkRoast();

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

            Beverage houseBlend = new HouseBlend();

            houseBlend = new Soya(houseBlend);
            houseBlend = new Mocha(houseBlend);
            houseBlend = new Whip(houseBlend);
            Console.WriteLine(houseBlend.GetDescription() + " $" + houseBlend.Cost());
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

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

            Beverage beverage1 = new DarkRoast();

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

            Beverage beverage2 = new HouseBlend();

            beverage2 = new Soy(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine(beverage2.Description + " $" + beverage2.Cost());
        }
Ejemplo n.º 16
0
        static void Main()
        {
            Beverage espresso = new Espresso();

            Console.WriteLine($"{espresso.GetDescription()} ${espresso.Cost()}");

            Beverage darkRoast = new DarkRoast();

            darkRoast = new Mocha(darkRoast);
            darkRoast = new Mocha(darkRoast);
            darkRoast = new Whip(darkRoast);
            Console.WriteLine($"{darkRoast.GetDescription()} ${darkRoast.Cost()}");

            Beverage houseBlend = new HouseBlend();

            houseBlend = new Soy(houseBlend);
            houseBlend = new Mocha(houseBlend);
            houseBlend = new Whip(houseBlend);
            Console.WriteLine($"{houseBlend.GetDescription()} ${houseBlend.Cost()}");
        }
        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());
        }
Ejemplo n.º 18
0
        public static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

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

            Beverage c1 = new DarkRoast();

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

            Beverage b3 = new HouseBlend();

            b3 = new Soy(b3);
            b3 = new Mocha(b3);
            b3 = new Whip(b3);
            Console.WriteLine(b3.GetDescription() + " $ " + b3.Cost());
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            IBeverage coffee = new Espresso();

            Console.WriteLine($"{coffee.Description}: £{coffee.Cost}");

            coffee = new DarkRoast();
            coffee = new Mocha(coffee);
            coffee = new Mocha(coffee);
            coffee = new Whip(coffee);

            Console.WriteLine($"{coffee.Description}: £{coffee.Cost}");

            //or, decorating decorators ...

            coffee = new Vanilla(new Mocha(new Mocha(new DarkRoast())));
            Console.WriteLine($"{coffee.Description}: £{coffee.Cost}");

            Console.ReadKey();
        }
Ejemplo n.º 20
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();
        }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starbuzz Coffee");

            Beverage beverage = new Espresso();

            Console.WriteLine($"{beverage.Description} : ${beverage.Cost()}");

            Beverage beverage1 = new DarkRoast();

            beverage1 = new Mocha(beverage1);
            beverage1 = new Mocha(beverage1);
            beverage1 = new Whip(beverage1);
            Console.WriteLine($"{beverage1.Description} : ${beverage1.Cost()}");

            Beverage beverage2 = new HouseBlend();

            beverage2 = new Soy(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine($"{beverage2.Description} : ${beverage2.Cost()}");
        }
Ejemplo n.º 22
0
        public Beverage MakeBeverage(BEVERAGE_TYPE bt, List <CONDIMENT_TYPE> clist)
        {
            switch (bt)
            {
            case BEVERAGE_TYPE.ESPRESSO:
            {
                Beverage item = new Espresso();
                item = ApplyCondiment(clist, item);
                return(item);
            }

            case BEVERAGE_TYPE.DRAKROAST:
            {
                Beverage item = new DarkRoast();
                item = ApplyCondiment(clist, item);
                return(item);
            }

            default:
                return(null);
            }
        }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            PrintMenu();

            // Order an espresso with no condiments
            Beverage beverage1 = new Espresso();

            Console.WriteLine(beverage1);

            // Order a dark roast with double mocha & whip on top
            Beverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine(beverage2);

            // House blend with soy mocha & whip
            Beverage beverage3 = new Whip(new Mocha(new Soy(new HouseBlend())));

            Console.WriteLine(beverage3);
        }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

            Console.WriteLine($"{beverage.Description} $ {beverage.Cost()}");

            Beverage beverage2 = new DarkRoast();

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


            Beverage beverage3 = new DarkRoast();

            beverage3 = new Soy(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine($"{beverage3.Description} $ {beverage3.Cost()}");

            Console.Read();
        }
        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());
        }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            Beverage one = new DarkRoast();

            one.setSize("tall");
            one = new Mocha(one);
            one = new Mocha(one);
            Console.WriteLine(one.getDesciption().ToString() + ": ${0}", one.cost().ToString());

            Beverage two = new Espresso();

            two.setSize("grande");
            Console.WriteLine(two.getDesciption().ToString() + ": ${0}", two.cost().ToString());

            Beverage three = new HouseBlend();

            three.setSize("venti");
            three = new Soy(three);
            three = new Mocha(three);
            three = new Whip(three);
            Console.WriteLine(three.getDesciption() + ": ${0}", three.cost());

            Console.Read();
        }
Ejemplo n.º 27
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.Default;

            Beverage beverage = new Espresso();

            Console.WriteLine(beverage.Description + " - Price: " + beverage.Cost() + " €");

            Beverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);

            Console.WriteLine(beverage2.Description + " - Price: " + beverage2.Cost() + " €");

            Beverage beverage3 = new HouseBlend();

            beverage3 = new Soy(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);

            Console.WriteLine(beverage3.Description + " - Price: " + beverage3.Cost() + " €");
        }
Ejemplo n.º 28
0
 public void DarkRoastCost()
 {
     IBeverage beverage = new DarkRoast();
     Assert.AreEqual<double>(2.99, beverage.Cost());
 }