|
@@ -6,6 +6,7 @@ public class Inventory {
|
6
|
6
|
static final String BRIE = "Aged Brie";
|
7
|
7
|
static final String BACK_PASS = "Backstage passes to a TAFKAL80ETC concert";
|
8
|
8
|
static final String SULFURAS = "Sulfuras, Hand of Ragnaros";
|
|
9
|
+ static final String CONJURED = "Conjured items by the magnificent wizard";
|
9
|
10
|
|
10
|
11
|
|
11
|
12
|
public Inventory(Item[] items) {
|
|
@@ -13,50 +14,62 @@ public class Inventory {
|
13
|
14
|
this.items = items;
|
14
|
15
|
}
|
15
|
16
|
|
16
|
|
- // Updates the quality for 1 day
|
17
|
17
|
public void updateQuality() {
|
18
|
18
|
|
19
|
|
- for (Item item: items) {
|
20
|
|
- // make a switch statement
|
|
19
|
+ for (Item item : items) {
|
21
|
20
|
|
22
|
|
- switch (item.getName()){
|
|
21
|
+ switch (item.getName()) {
|
23
|
22
|
|
24
|
|
- case BRIE:
|
|
23
|
+ case BRIE:
|
|
24
|
+ if (!checkSellInNegative(item)) {
|
|
25
|
+ adjustItemQuality(item, 1);
|
|
26
|
+ } else {
|
|
27
|
+ adjustItemQuality(item, 2);
|
|
28
|
+ }
|
|
29
|
+ decreaseSellIn(item);
|
|
30
|
+ break;
|
25
|
31
|
|
26
|
|
- adjustItemQuality(item, 1);
|
|
32
|
+ case BACK_PASS:
|
27
|
33
|
|
28
|
|
- decreaseSellIn(item);
|
29
|
|
- break;
|
|
34
|
+ if (checkPassSellIn5(item)) {
|
|
35
|
+ adjustItemQuality(item, 3);
|
30
|
36
|
|
31
|
|
- case BACK_PASS:
|
|
37
|
+ } else if (checkPassSellIn10(item)) {
|
|
38
|
+ adjustItemQuality(item, 2);
|
32
|
39
|
|
33
|
|
- // Check sell in because the sell in value dictates the quality modifier
|
|
40
|
+ } else if (checkSellInNegative(item)) {
|
|
41
|
+ setQualityZero(item);
|
34
|
42
|
|
35
|
|
- if (checkPassSellIn5(item)) {
|
36
|
|
- adjustItemQuality(item, 3);
|
|
43
|
+ } else {
|
|
44
|
+ adjustItemQuality(item, 1);
|
|
45
|
+ }
|
37
|
46
|
|
38
|
|
- } else if (checkPassSellIn10(item)) {
|
39
|
|
- adjustItemQuality(item, 2);
|
|
47
|
+ decreaseSellIn(item);
|
40
|
48
|
|
41
|
|
- } else if (checkPassSellInNegative(item)) {
|
42
|
|
- setQualityZero(item);
|
43
|
|
- } else {
|
44
|
|
- adjustItemQuality(item, 1);
|
45
|
|
- }
|
46
|
|
- decreaseSellIn(item);
|
|
49
|
+ break;
|
47
|
50
|
|
48
|
|
- break;
|
|
51
|
+ case SULFURAS:
|
|
52
|
+ item.setQuality(80);
|
|
53
|
+ item.setSellIn(item.getSellIn());
|
49
|
54
|
|
50
|
|
- case SULFURAS:
|
51
|
|
- item.setQuality(80);
|
52
|
|
- item.setSellIn(item.getSellIn());
|
|
55
|
+ break;
|
53
|
56
|
|
54
|
|
- break;
|
|
57
|
+ case CONJURED:
|
|
58
|
+ if (!checkSellInNegative(item)) {
|
|
59
|
+ adjustItemQuality(item, -2);
|
|
60
|
+ } else {
|
|
61
|
+ adjustItemQuality(item, -4);
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ decreaseSellIn(item);
|
|
65
|
+ break;
|
|
66
|
+
|
|
67
|
+ default:
|
|
68
|
+ break;
|
55
|
69
|
}
|
56
|
70
|
}
|
57
|
71
|
}
|
58
|
72
|
|
59
|
|
-
|
60
|
73
|
public void decreaseSellIn(Item name) {
|
61
|
74
|
name.setSellIn(name.getSellIn() - 1);
|
62
|
75
|
|
|
@@ -80,7 +93,7 @@ public class Inventory {
|
80
|
93
|
return false;
|
81
|
94
|
}
|
82
|
95
|
|
83
|
|
- public boolean checkPassSellInNegative(Item item) {
|
|
96
|
+ public boolean checkSellInNegative(Item item) {
|
84
|
97
|
|
85
|
98
|
if (item.getSellIn() < 0) {
|
86
|
99
|
return true;
|
|
@@ -99,126 +112,15 @@ public class Inventory {
|
99
|
112
|
|
100
|
113
|
public void adjustItemQuality(Item name, int qualityIncrement) {
|
101
|
114
|
|
102
|
|
- if (name.getQuality() + qualityIncrement < 50) {
|
|
115
|
+ if (name.getQuality() + qualityIncrement < 0) {
|
|
116
|
+ setQualityZero(name);
|
|
117
|
+
|
|
118
|
+ } else if ((name.getQuality() + qualityIncrement < 50) && (name.getQuality() + qualityIncrement >= 0)) {
|
103
|
119
|
name.setQuality(name.getQuality() + qualityIncrement);
|
|
120
|
+
|
104
|
121
|
} else {
|
105
|
122
|
setQualityMax(name);
|
106
|
123
|
}
|
107
|
124
|
|
108
|
125
|
}
|
109
|
|
-
|
110
|
|
- public Item[] getItems(){
|
111
|
|
- return this.items;
|
112
|
|
- }
|
113
|
|
-
|
114
|
|
-
|
115
|
|
-
|
116
|
|
-
|
117
|
|
-
|
118
|
|
-
|
119
|
|
-
|
120
|
|
-
|
121
|
|
-
|
122
|
|
-
|
123
|
|
-
|
124
|
|
-
|
125
|
|
-
|
126
|
|
-
|
127
|
|
-
|
128
|
|
-
|
129
|
|
-
|
130
|
|
-
|
131
|
|
-// // Old Code
|
132
|
|
-// public void updateQuality() {
|
133
|
|
-// // Giant for loop representing the "day" each day, the quality's of items change.
|
134
|
|
-//
|
135
|
|
-// for (int i = 0; i < items.length; i++) {
|
136
|
|
-//
|
137
|
|
-// // This if statement checks if it is NOT aged brie and NOT backstage passes
|
138
|
|
-// if (!items[i].getName().equals("Aged Brie")
|
139
|
|
-// && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
140
|
|
-// // if it's not brie and bspasses
|
141
|
|
-// if (items[i].getQuality() > 0) {
|
142
|
|
-// // checks if the quality is over 0
|
143
|
|
-// if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
144
|
|
-// // as long as it's not surlfuras...
|
145
|
|
-// // quantity is decreased by 1
|
146
|
|
-// items[i].setQuality(items[i].getQuality() - 1);
|
147
|
|
-// }
|
148
|
|
-// }
|
149
|
|
-//
|
150
|
|
-//
|
151
|
|
-//
|
152
|
|
-// } else {
|
153
|
|
-//
|
154
|
|
-// // Next leg of IF statement quality < 50 then increase quality by 1
|
155
|
|
-//
|
156
|
|
-// if (items[i].getQuality() < 50) {
|
157
|
|
-// // if the quality is below 50
|
158
|
|
-// items[i].setQuality(items[i].getQuality() + 1);
|
159
|
|
-// // the quality is increased by 1
|
160
|
|
-//
|
161
|
|
-// // stuff about backstage passes
|
162
|
|
-// if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
|
163
|
|
-// // if the item is a backstagepass
|
164
|
|
-//
|
165
|
|
-// if (items[i].getSellIn() < 11) {
|
166
|
|
-// // and if the backstage pass has to sell in 11 days
|
167
|
|
-// if (items[i].getQuality() < 50) {
|
168
|
|
-// // and the quality is below 50
|
169
|
|
-// items[i].setQuality(items[i].getQuality() + 1);
|
170
|
|
-// // then add 1 to the quality
|
171
|
|
-// }
|
172
|
|
-// }
|
173
|
|
-//
|
174
|
|
-// if (items[i].getSellIn() < 6) {
|
175
|
|
-// // if the bspass has to sell in 6 days
|
176
|
|
-// if (items[i].getQuality() < 50) {
|
177
|
|
-// // and the quality is less than 50
|
178
|
|
-// items[i].setQuality(items[i].getQuality() + 1);
|
179
|
|
-// // then add 1 to the quality
|
180
|
|
-// }
|
181
|
|
-// }
|
182
|
|
-// }
|
183
|
|
-// }
|
184
|
|
-// }
|
185
|
|
-//
|
186
|
|
-// // another if the item IS NOT SULFURAS
|
187
|
|
-//
|
188
|
|
-// if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
189
|
|
-// items[i].setSellIn(items[i].getSellIn() - 1);
|
190
|
|
-// }
|
191
|
|
-// // then decrease the sellin day by 1
|
192
|
|
-//
|
193
|
|
-//
|
194
|
|
-// // checks the items sell in
|
195
|
|
-// // if the items sell in is less than 0 (no sellin is negative)
|
196
|
|
-// if (items[i].getSellIn() < 0) {
|
197
|
|
-//
|
198
|
|
-// if (!items[i].getName().equals("Aged Brie")) {
|
199
|
|
-// // and the item IS NOT Brie
|
200
|
|
-// if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
201
|
|
-// // and the item IS NOT BSPASSES
|
202
|
|
-// if (items[i].getQuality() > 0) {
|
203
|
|
-// // if the item quality is greater than 0,
|
204
|
|
-//
|
205
|
|
-// if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
206
|
|
-// // and the item is NOT SULFURAS,
|
207
|
|
-// items[i].setQuality(items[i].getQuality() - 1);
|
208
|
|
-// // the item quality -1
|
209
|
|
-// }
|
210
|
|
-// }
|
211
|
|
-// } else { // if the item IS a backstage pass
|
212
|
|
-// items[i].setQuality(items[i].getQuality() - items[i].getQuality());
|
213
|
|
-// }
|
214
|
|
-// } else { // if the item IS BRIE
|
215
|
|
-// if (items[i].getQuality() < 50) {
|
216
|
|
-// // BRIE QUALITY is LESS THAN 50
|
217
|
|
-// items[i].setQuality(items[i].getQuality() + 1);
|
218
|
|
-// // Increase Brie's quality by 1
|
219
|
|
-// }
|
220
|
|
-// }
|
221
|
|
-// }
|
222
|
|
-// }
|
223
|
|
-// }
|
224
|
|
-}
|
|
126
|
+}
|