Beispiel #1
0
        static void Main(string[] args)
        {
            Baverage baverage = new DarkRoast("Какое-то кофе!");

            baverage = new Milk(baverage, "Молоко!");
            baverage = new Milk(baverage, "Молоко!");
            baverage = new Soy(baverage, "Soy!");
            Console.WriteLine(baverage.getDescription() + "=" + baverage.cost() + "$");
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            // 베이스 음료를 선택하고 첨가물을 넣어주어. 동적으로 서브 클래스를 첨가해줌.
            // 좋은 구조인지는 솔직히 의문...
            Beverage coldbrewWithMochaSoy = new ColdBrew();

            coldbrewWithMochaSoy = new Mocha(coldbrewWithMochaSoy);
            coldbrewWithMochaSoy = new Soy(coldbrewWithMochaSoy);

            Console.Write(coldbrewWithMochaSoy.getCost());
            Console.Write(coldbrewWithMochaSoy.getDescription());
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("woof!");

            Beverage my_bev = new Espresso(Beverage.bev_size.VENTI);
            System.Console.WriteLine("my_bev[" + my_bev.getDescription() + "]");
            System.Console.WriteLine("my_bev.cost[" + my_bev.cost() + "]");

            my_bev = new Mocha(my_bev);
            System.Console.WriteLine("my_bev[" + my_bev.getDescription() + "]");
            System.Console.WriteLine("my_bev.cost[" + my_bev.cost() + "]");
            
            my_bev = new Mocha(my_bev);
            System.Console.WriteLine("my_bev[" + my_bev.getDescription() + "]");
            System.Console.WriteLine("my_bev.cost[" + my_bev.cost() + "]");

            my_bev = new Soy(my_bev);
            System.Console.WriteLine("my_bev[" + my_bev.getDescription() + "]");
            System.Console.WriteLine("my_bev.cost[" + my_bev.cost() + "]");

            my_bev = new Whip(my_bev);
            System.Console.WriteLine("my_bev[" + my_bev.getDescription() + "]");
            System.Console.WriteLine("my_bev.cost[" + my_bev.cost() + "]");

            my_bev = new Whip(my_bev);
            System.Console.WriteLine("my_bev[" + my_bev.getDescription() + "]");
            System.Console.WriteLine("my_bev.cost[" + my_bev.cost() + "]");

        }