예제 #1
0
 static void HaveADrink(HotDrink h)
 {
     h.AddMilk();
     h.Drink();
     if (h is ICup)
     {
         ICup cupOfDrink = h as ICup;
         //ICup cupOfDrink =(ICup)h;
         cupOfDrink.Wash();
     }
 }
예제 #2
0
 static void Drinks(HotDrink drink)
 {
     drink.AddMilk();
     drink.AddSugar();
     drink.Drink();
     if (drink is ICup)
     {
         ICup interfaceCup = drink as ICup;
         interfaceCup.Refill();
         interfaceCup.Wash();
     }
 }
예제 #3
0
        public void CupOfHotDrink()
        {
            CupOfCoffe coffe = new CupOfCoffe();
            CupOfTea   tea   = new CupOfTea();

            coffe.AddMilk();
            coffe.Drink();
            tea.AddMilk();
            tea.Drink();
            ICup cupcofee = coffe;
            ICup cuptea   = tea;

            cupcofee.Wash();
            cuptea.Wash();
        }
예제 #4
0
    static void ManipulateDrink(HotDrink drink)
    {
        ICup cupInterface = drink as ICup;

        cupInterface.Wash();
    }