update,
This commit is contained in:
19
_resources/it114105/itp4510/Lab01/Lab1.2/q1/Drink.java
Normal file
19
_resources/it114105/itp4510/Lab01/Lab1.2/q1/Drink.java
Normal file
@@ -0,0 +1,19 @@
|
||||
public class Drink extends Food {
|
||||
protected int volume;
|
||||
|
||||
public Drink(String name, int price, int volume) {
|
||||
super(name, price);
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public void setPrice(int price) {
|
||||
if (price < 5)
|
||||
this.price = 5;
|
||||
else
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return super.toString() + ", volume=" + volume;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user