Files
004_comission/_resources/it114105/itp4510/Lab01/Lab1.2/q1/Coffee.java
louiscklaw 6c60a73f30 update,
2025-01-31 19:15:17 +08:00

22 lines
536 B
Java

public class Coffee extends Drink {
protected boolean isSweet;
public Coffee(String name, int price, int volume, boolean isSweet) {
super(name, price, volume);
this.isSweet = isSweet;
}
public String toString() {
if (isSweet)
return super.toString() + ", sweet";
else
return super.toString() + ", not sweet";
}
public void setPrice(int price) {
if (price < 10)
this.price = 10;
else
super.setPrice(price);
}
}