Westonci.ca is the Q&A platform that connects you with experts who provide accurate and detailed answers. Get detailed answers to your questions from a community of experts dedicated to providing accurate information. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.

Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: g

Sagot :

Answer:

interface HowToMakeDrink{

   public void ingredient();

   public void makeDrink();

}

class Coffee implements HowToMakeDrink{

   String type;

   double price;

   String name;

   public void ingredient(String ...items){

       for (String i : items){

           System.out.println('%s\n', i);

       }

   }

   public makeDrink(){

       System.out.println('Your '+ %s +' is ready', this.name);

   }

   public getType(){

       return this.type;

   }

   public getPrice(){

       return this.price;

   }

   public getName(){

       return this.name;

   }

   public setType(String type){

       this.type = type;

   }

   public setPrice(double price){

       this.price = price;

   }

   public setName(String name-){

       this.name = name;

   }

}

Explanation:

The Coffee class is used to implement the HowToMakeDrink interface. The class uses the set and get methods to assign and retrieve the values of the class variables. It so implements the ingredient and makeDrink methods of the required interface.

Thanks for stopping by. We are committed to providing the best answers for all your questions. See you again soon. Thanks for using our platform. We aim to provide accurate and up-to-date answers to all your queries. Come back soon. Westonci.ca is here to provide the answers you seek. Return often for more expert solutions.