-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHamburger.java
More file actions
62 lines (58 loc) · 2.16 KB
/
Copy pathHamburger.java
File metadata and controls
62 lines (58 loc) · 2.16 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.company;
public class Hamburger {
private String name;
private String meat;
private double price;
private String breadType;
private String addition1Name;
private double addition1Price;
private String addition2Name;
private double addition2Price;
private String addition3Name;
private double addition3Price;
private String addition4Name;
private double addition4Price;
public Hamburger(String name, String meat, double price, String breadType) {
this.name = name;
this.meat = meat;
this.price = price;
this.breadType = breadType;
}
public void addHamburgerAddition1(String name, double price){
this.addition1Name=name;
this.addition1Price=price;
}
public void addHamburgerAddition2(String name, double price){
this.addition2Name=name;
this.addition2Price=price;
}
public void addHamburgerAddition3(String name, double price){
this.addition3Name=name;
this.addition3Price=price;
}
public void addHamburgerAddition4(String name, double price){
this.addition4Name=name;
this.addition4Price=price;
}
public double itemizeHamburger(){
double hamburgerPrice=this.price;
System.out.println(this.name+" hamburger on a "+this.breadType+" roll. Price is "+this.price);
if (this.addition1Name != null){
hamburgerPrice +=this.addition1Price;
System.out.println("Added "+this.addition1Name+" for an extra "+this.addition1Price);
}
if (this.addition2Name != null){
hamburgerPrice +=this.addition2Price;
System.out.println("Added "+this.addition2Name+" for an extra "+this.addition2Price);
}
if (this.addition3Name != null){
hamburgerPrice +=this.addition3Price;
System.out.println("Added "+this.addition3Name+" for an extra "+this.addition3Price);
}
if (this.addition4Name != null){
hamburgerPrice +=this.addition4Price;
System.out.println("Added "+this.addition4Name+" for an extra "+this.addition4Price);
}
return hamburgerPrice;
}
}