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.