Repository navigation
Expand file tree
/
Copy pathHamburger.java
More file actions
52 lines (42 loc) · 1.36 KB
/
Copy pathHamburger.java
File metadata and controls
52 lines (42 loc) · 1.36 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
public class Hamburger {
private BreadRoll breadRoll;
private Meat meat;
private int additionsCount;
private String additionsList = "";
private int price;
public Hamburger(int breadRollNumber, int meatNumber) {
breadRoll = new BreadRoll(breadRollNumber);
meat = new Meat(meatNumber);
System.out.println("Creating a " + this.getClass().getCanonicalName() + ".");
this.additionsCount = 0;
this.price = 4;
}
public void additionsOverload() {
System.out.println("You can only have up to 4 additions.");
}
public void setAdditionsCount(int additionsCount) {
this.additionsCount = additionsCount;
}
public String getAdditionsList() {
return additionsList;
}
public void addToList(String add) {
this.additionsList += add;
}
public int getAdditionsCount() {
return additionsCount;
}
public void newAddition() {
additionsCount++;
}
public void raisePrice(int extra) {
this.price += extra;
}
public int getPrice() {
return price;
}
public void summary() {
System.out.println("You ordered a burger on " + breadRoll.getBreadRollType() + " bread and " + meat.getMeatType() +
" meat, with extra " + getAdditionsList() + "which will cost you " + getPrice() + " $.");
}
}