コード例 #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
ファイル: Program.cs プロジェクト: GamezAr94/Ch08Ex05
 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();
    }