-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBakery.java
More file actions
40 lines (38 loc) · 1.08 KB
/
Bakery.java
File metadata and controls
40 lines (38 loc) · 1.08 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
/**
* Places the order for each cake wanting to be made within the bakery from several options for a cake.
* @author Matt Duggan
*
*/
public class Bakery {
/**
* This creates a type of cake to be decorated and displays back to the user the details of the cake.
* @param type The cake the user ordered from the driver.
* @return The display to the user of the cake being made.
*/
public Cake orderCake(String type) {
Cake cake = this.createCake(type);
cake.createCake();
System.out.println("Price: $" + cake.getPrice());
return cake;
}
/**
* Creates a new cake determined by the customer/driver.
* @param type The customers order.
* @return The cake object/the cake and its attributes.
*/
private Cake createCake(String type) {
if(type == "birthday cake"){
return new BirthdayCake();
}
else if(type == "carrot cake") {
return new CarrotCake();
}
else if(type == "black forest cake"){
return new BlackForestCake();
}
else{
System.out.println("This is not a valid cake");
return null;
}
}
}