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