-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCoffee.java
110 lines (90 loc) · 2.98 KB
/
Coffee.java
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import java.util.ArrayList;
public class Coffee {
private String type;
private int caffeine; // measured in mg
private int size; // measured in oz
static Coffee c1 = new Coffee("Brewed Coffee", 95, 8);
static Coffee c2 = new Coffee("Espresso", 64, 1);
static Coffee c3 = new Coffee("Instant Coffee", 62, 8);//TODO: change this and brewed coffee's caffeine intake back to its actual values
static Coffee c4 = new Coffee("Brewed Decaf Coffee", 2, 8);
static Coffee stb1 = new Coffee("Caffe Americano", 150, 12);
static Coffee stb2 = new Coffee("Blonde Roast", 270, 12);
static Coffee stb3 = new Coffee("Cappuccino", 150, 16);
static Coffee stb4 = new Coffee("Flat White", 130, 12);
static Coffee stb5 = new Coffee("Caffe Latte", 75, 12);
static Coffee stb6 = new Coffee("Caramel Macchiato", 75, 12);
static Coffee stb7 = new Coffee("Caffe Latte", 75, 12);
static Coffee stb8 = new Coffee("Caffe Mocha", 95, 12);
static Coffee stb9 = new Coffee("White Chocolate Mocha", 75, 12);
private static ArrayList<Coffee> DRINKS = new ArrayList<Coffee>(); //TODO: add drinks to array
//constructor
public Coffee(String type, int caffeine, int size){
this.type = type;
this.caffeine = caffeine;
this.size = size;
}
public static void addData() {
Coffee.addDrink(c1);
Coffee.addDrink(c2);
Coffee.addDrink(c3);
Coffee.addDrink(c4);
Coffee.addDrink(stb1);
Coffee.addDrink(stb2);
Coffee.addDrink(stb3);
Coffee.addDrink(stb4);
Coffee.addDrink(stb5);
Coffee.addDrink(stb6);
Coffee.addDrink(stb7);
Coffee.addDrink(stb8);
Coffee.addDrink(stb9);
}
//getters
public String getType() {
return type;
}
public int getCaffeine() {
return caffeine;
}
public int getSize() {
return size;
}
public static ArrayList<Coffee> getDrinksList() {
return DRINKS;
}
//setters
public void setType(String type) {
this.type = type;
}
public void setCaffeine(int caffeine) {
this.caffeine = caffeine;
}
public void setSize(int size) {
this.size = size;
}
@Override
public boolean equals(Object other) {
if (other instanceof Coffee) {
Coffee cOther = (Coffee) other;
if (this.type.equals(cOther.type)
&& this.caffeine == cOther.caffeine
&& this.size == cOther.size) {
return true;
}
}
return false;
}
//arraylist drinks modifiers
public static boolean checkDrink(Coffee c) {//TODO: take this out if not needed
for (int i = 0; i < DRINKS.size(); i++) {
if(c.equals(DRINKS.get(i))) {
return true;
}
}
return false;
}
public static void addDrink(Coffee c) {
if (!checkDrink(c)) {
DRINKS.add(c);
}
}
}