-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHealthyBurger.java
More file actions
35 lines (31 loc) · 1.17 KB
/
Copy pathHealthyBurger.java
File metadata and controls
35 lines (31 loc) · 1.17 KB
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
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");
}
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;
}
}