コード例 #1
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

            PrintBeverageCost(beverage);

            Beverage beverage2 = new DarkRoast();

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

            Beverage beverage3 = new HouseBlend();

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

            Beverage beverage4 = new Decaf();

            beverage4 = new Latte(beverage4);
            beverage4 = new Mocha(beverage4);
            beverage4 = new Whip(beverage4);
            PrintBeverageCost(beverage4);

            Console.ReadLine();
        }
コード例 #2
0
        public void Run()
        {
            var decaf = new Decaf();

            Console.WriteLine($"{decaf.Description()} cost is ${decaf.Cost()}");

            var decafWithCaramel = new Caramel(decaf);

            Console.WriteLine($"{decafWithCaramel.Description()} cost is ${decafWithCaramel.Cost()}");

            var decafWithCaramelPlusSoyMilk = new SoyMilk(decafWithCaramel);

            Console.WriteLine($"{decafWithCaramelPlusSoyMilk.Description()} cost is ${decafWithCaramelPlusSoyMilk.Cost()}");

            var decafWithSoy = new SoyMilk(decaf);

            Console.WriteLine($"{decafWithSoy.Description()} cost is ${decafWithSoy.Cost()}");

            var espresso = new Espresso();

            Console.WriteLine($"{espresso.Description()} cost is ${espresso.Cost()}");

            var doubleEspresso = new ExtraEspresso(espresso);

            Console.WriteLine($"{doubleEspresso.Description()} cost is ${doubleEspresso.Cost()}");
        }
コード例 #3
0
        static void Main(string[] args)
        {
            var espresso    = new Espresso();
            var espressoSoy = new Soy(espresso);

            System.Console.WriteLine("The cost of a esspresso with soy is {0} dollars", espressoSoy.Cost());
            var decaf        = new Decaf();
            var decafCaramel = new Caramel(decaf);

            System.Console.WriteLine("The cost of a decaf with caramel is {0} dollars", decafCaramel.Cost());
        }
コード例 #4
0
        static void Main(string[] args)
        {
            // Cost of Decaf with Whipped cream and Mochs must be 21.8
            var myHealtyBeverage = new DecafFirstAttempt(hasMocha: true, hasWhip: true);

            Console.WriteLine($"Cost of Decaf with Whipped cream and Mochs must be 21.8. Thas is {myHealtyBeverage.Cost() == 21.8}.");

            var       mySimpleHealthyBeverage          = new Decaf();
            IBeverage mySimpleHealthyBeverageDecorated = new WhipDecorator(
                new MochaDecorator(mySimpleHealthyBeverage));

            Console.WriteLine($"Cost of Decaf with Whipped cream and Mochs must be 21.8. Thas is {mySimpleHealthyBeverageDecorated.Cost() == 21.8}.");
        }
コード例 #5
0
        static void Main(string[] args)
        {
            Beverage beverage1 = new Espresso();

            Console.WriteLine("{0} costs {1}$", beverage1.GetDescription(), beverage1.cost());

            Beverage beverage2 = new DarkRoast();

            beverage2 = new Milk(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            beverage2.GetDescription();
            Console.WriteLine("{0} costs {1}$", beverage2.GetDescription(), beverage2.cost());

            Beverage beverage3 = new Decaf();

            beverage3.setSize(Beverage.Size.Venti);
            beverage3 = new Soy(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine("{0} costs {1}$", beverage3.GetDescription(), beverage3.cost());

            Console.ReadLine();
        }