Get the best answers to your questions with the help of IDNLearn.com's experts. Discover in-depth answers to your questions from our community of experienced professionals.
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.
We appreciate your contributions to this forum. Don't forget to check back for the latest answers. Keep asking, answering, and sharing useful information. IDNLearn.com has the solutions to your questions. Thanks for stopping by, and come back for more insightful information.