static void HaveADrink(HotDrink h) { h.AddMilk(); h.Drink(); if (h is ICup) { ICup cupOfDrink = h as ICup; //ICup cupOfDrink =(ICup)h; cupOfDrink.Wash(); } }
static void Drinks(HotDrink drink) { drink.AddMilk(); drink.AddSugar(); drink.Drink(); if (drink is ICup) { ICup interfaceCup = drink as ICup; interfaceCup.Refill(); interfaceCup.Wash(); } }
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(); }
static void ManipulateDrink(HotDrink drink) { ICup cupInterface = drink as ICup; cupInterface.Wash(); }