Untitled
unknown
plain_text
3 years ago
2.5 kB
11
Indexable
public class Hamburger {
private String rollType;
private String meat;
private double basePrice;
private String name;
private String addition;
private int countAddition;
public Hamburger(String rollType, String meat, double basePrice, String name) {
this.rollType = rollType;
this.meat = meat;
this.basePrice = basePrice;
this.name = name;
}
public void addItem(String addition) {
if (countAddition < 4) {
System.out.println("You added " + addition + " to your burger.");
this.countAddition++;
} else {
System.out.println("You cannot add more items.");
}
}
public int getCountAddition() {
return countAddition;
}
public double additionsPrice () {
return countAddition * 0.5;
}
public void getInfo () {
System.out.println("The base price is " + basePrice + "$");
System.out.println("Your additions items cost " + additionsPrice() + "$");
System.out.println("Your total is " + basePrice + additionsPrice() + "$");
}
}
public class HealthyBurger extends Hamburger {
private String itemOne;
private String itemTwo;
private int countAddition = 2;
public HealthyBurger(String meat, double basePrice, String name) {
super("brown rye bread roll", meat, basePrice, "Healthy Burger");
}
@Override
public void addItem(String addition) {
if (countAddition < 6) {
this.countAddition++;
super.addItem(addition);
}
}
@Override
public double additionsPrice() {
return super.additionsPrice();
}
@Override
public void getInfo() {
super.getInfo();
}
@Override
public int getCountAddition() {
return super.getCountAddition();
}
}
public class DeluxeBurger extends Hamburger {
private boolean chips;
private boolean drink;
private int countAddition;
public DeluxeBurger(String rollType, String meat, double basePrice, String name, boolean chips, boolean drink, int countAddition) {
super(rollType, meat, basePrice, name);
this.chips = true;
this.drink = true;
this.countAddition = 0;
}
@Override
public void addItem(String addition) {
super.addItem(addition);
}
@Override
public void getInfo() {
super.getInfo();
}
}
Editor is loading...