jaguRita

jaguRita

  • NA
  • 40
  • 0

Plz Clear my dout -Interface & Abstract

Aug 22 2007 6:36 PM

   Hello all, (please try to give possible way to slove this.)

  • An abstract class called HotDrink that has the methods Drink(), AddMilk(), and AddSugar(), and the properties Milk, and Sugar.

  • An interface called ICup that has the methods Refill() and Wash(), and the properties Color and Volume.

  • A class called CupOfCoffee that derives from HotDrink, supports the ICup interface, and has the additional property BeanType.

  • A class called CupOfTea that derives from HotDrink, supports the ICup interface, and has the additional property LeafType.

  • Write some code for a function that will accept either of the two cup objects in the preceding example as a parameter. The function should call the AddMilk(), Drink(), and Wash() methods for any cup object it is passed.

  • For this program,i have written all the abstract class,interface and 2 derived classes..But i couldnt understand the final point.

    I have created one function in both derived classes.

    public void Method1(object o)

    {

    CupofCoffee c1 = (CupofCoffee)o;

    c1.AddMilk();   c1.Drink();   c1.wash();

    }

    The same like one in another derived class.But am stuck with this.I dont know how to create Mainmethod.Can anyone of u help to resove this program.Thanks 4 ur help.

     


    Answers (1)