-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCake.java
More file actions
70 lines (64 loc) · 1.74 KB
/
Cake.java
File metadata and controls
70 lines (64 loc) · 1.74 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
63
64
65
66
67
68
69
70
import java.util.ArrayList;
/**
* This defines a cake and its attributes.
* @author Matt Duggan
*
*/
public class Cake {
protected String name;
protected double price;
protected int NumLayers;
protected ArrayList<String> decorations = new ArrayList<String>();
protected Shape shape;
protected String flavor;
protected String icing;
/**
* Displays the type of cake being made, its additions, and the price.
*/
public void createCake() {
createLayers();
frostCake();
addDecorations();
}
/**
* Determines the type of cake and displays the type of cake being made.
*/
private void createLayers() {
if(shape == Shape.CUPCAKES) {
System.out.println("Creating " + this.flavor + " cupcakes");
}
else if(shape == Shape.BUNT) {
System.out.println("Creating a " + this.flavor + " bunt cake");
}
else if(NumLayers == 1) {
System.out.println("Creating a 1 layer " + this.shape.toString().toLowerCase() + " " + this.flavor + " cake");
}
else if(NumLayers >= 1) {
System.out.println("Creating a " + this.NumLayers + " layered " + this.shape.toString().toLowerCase() + " " + this.flavor + " cake");
}
else {
System.out.println("This is not a valid cake. Try one of our many options!");
}
}
/**
* Displays the type of frosting.
*/
private void frostCake() {
System.out.println("Frost cake with " + this.icing + " icing.");
}
/**
* Displays the type of additions being added.
*/
private void addDecorations() {
for(String dec : decorations) {
System.out.println("Adding " + dec + ".");
}
}
/**
* Gets the price for the cake.
* @return The determined price.
*/
public double getPrice() {
return this.price;
}
}