-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWithFlavor.java
More file actions
46 lines (38 loc) · 999 Bytes
/
WithFlavor.java
File metadata and controls
46 lines (38 loc) · 999 Bytes
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
/*
* Author: Sam Braude (Red ID: 826984009)
* Intermediate Computer Programming Lab (CS 160L)
* Erin Ratelle
* June 28, 2023
*/
import java.util.ArrayList;
import java.util.List;
public class WithFlavor extends CoffeeDecorator {
/*
* Using an enum for syrup flavors saves time so that there is no need
* to type out every type of syrup.
*/
enum Syrup {
CARAMEL,
MOCHA,
VANILLA
}
private Syrup flavor;
public WithFlavor(Coffee c, Syrup s) {
super(c);
flavor = s;
}
@Override
public double getCost() {
return super.getCost() + 0.35;
}
@Override
public List<String> getIngredients() {
List<String> ingredients = new ArrayList<>();
ingredients.add(flavor.name() + " Syrup");
return ingredients;
}
@Override
public String printCoffee() {
return super.printCoffee() + " with " + flavor;
}
}