IDNLearn.com provides a user-friendly platform for finding answers to your questions. Ask any question and receive comprehensive, well-informed responses from our dedicated team of experts.
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 value your participation in this forum. Keep exploring, asking questions, and sharing your insights with the community. Together, we can find the best solutions. Thank you for choosing IDNLearn.com. We’re dedicated to providing clear answers, so visit us again for more solutions.