-
Notifications
You must be signed in to change notification settings - Fork 0
/
HealthyBurger.java
40 lines (33 loc) · 1.24 KB
/
HealthyBurger.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.company;
public class HealthyBurger extends Hamburger{
private String healthyExtra1Name;
private double healthyExtra1Price;
private String healthyExtra2Name;
private double healthyExtra2Price;
public HealthyBurger(String meat, double price) {
super("Healthy", meat, price, "Brown rye");
}
public void addHealthAddition1(String name, double price){
this.healthyExtra1Name = name;
this.healthyExtra1Price = price;
}
public void addHealthAddition2(String name, double price){
this.healthyExtra2Name = name;
this.healthyExtra2Price = price;
}
@Override
public double itemizeHamburger() {
double hamburgerPrice = super.itemizeHamburger();
if(this.healthyExtra1Name != null){
hamburgerPrice += this.healthyExtra1Price;
System.out.println("Added " + this.healthyExtra1Name + " for an extra " +
this.healthyExtra1Price);
}
if(this.healthyExtra2Name != null){
hamburgerPrice += this.healthyExtra2Price;
System.out.println("Added " + this.healthyExtra2Name + " for an extra " +
this.healthyExtra2Price);
}
return hamburgerPrice;
}
}