コード例 #1
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()}");
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Expresso cafeExpresso                   = new Expresso();
            Caramel  cafeExpressoWithCaramel        = new Caramel(cafeExpresso);
            Milk     cafeExpressoWithCaramelAndMilk = new Milk(cafeExpressoWithCaramel);

            Console.WriteLine("Expresso: " + cafeExpresso.Cost());
            Console.WriteLine("Expresso Caramel: " + cafeExpressoWithCaramel.Cost());
            Console.WriteLine("Expresso Caramel And Milk: " + cafeExpressoWithCaramelAndMilk.Cost());
            Console.ReadKey();
        }
コード例 #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());
        }