|
@@ -10,56 +10,62 @@ public class Inventory {
|
10
|
10
|
}
|
11
|
11
|
|
12
|
12
|
|
|
13
|
+
|
|
14
|
+
|
13
|
15
|
public void updateQuality() {
|
|
16
|
+
|
14
|
17
|
for (int i = 0; i < items.length; i++) {
|
15
|
|
- if (!items[i].getName().equals("Aged Brie")
|
16
|
|
- && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
17
|
|
- if (items[i].getQuality() > 0) {
|
18
|
|
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
19
|
|
- items[i].setQuality(items[i].getQuality() - 1);
|
20
|
|
- }
|
21
|
|
- }
|
22
|
|
- } else {
|
23
|
|
- if (items[i].getQuality() < 50) {
|
|
18
|
+
|
|
19
|
+ if (!items[i].getName().equals("Aged Brie") &&
|
|
20
|
+ !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert") &&
|
|
21
|
+ !items[i].getName().equals("Sulfuras, Hand of Ragnaros") &&
|
|
22
|
+ items[i].getQuality() > 0) {
|
|
23
|
+ items[i].setQuality(items[i].getQuality() - 1);
|
|
24
|
+ }
|
|
25
|
+ /// ^^^ this whole block is telling you to decrease item quality by 1 if the item
|
|
26
|
+ /// isn't aged brie, backstage pass, isn't already at 0 quality, and isn't sulfuras.
|
|
27
|
+
|
|
28
|
+ //// if the items name is Aged Brie or backstage pass or sulfuras, and if quality >0 and sellin <0
|
|
29
|
+ else if (items[i].getQuality() < 50) {
|
|
30
|
+ items[i].setQuality(items[i].getQuality() + 1);
|
|
31
|
+
|
|
32
|
+ // // combined >> if sellin < 11 & the item is a backstage pass, + 1
|
|
33
|
+ if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert" &&
|
|
34
|
+ items[i].getSellIn() < 11) {
|
24
|
35
|
items[i].setQuality(items[i].getQuality() + 1);
|
|
36
|
+ }
|
25
|
37
|
|
26
|
|
- if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
|
27
|
|
- if (items[i].getSellIn() < 11) {
|
28
|
|
- if (items[i].getQuality() < 50) {
|
29
|
|
- items[i].setQuality(items[i].getQuality() + 1);
|
30
|
|
- }
|
31
|
|
- }
|
32
|
|
-
|
33
|
|
- if (items[i].getSellIn() < 6) {
|
34
|
|
- if (items[i].getQuality() < 50) {
|
35
|
|
- items[i].setQuality(items[i].getQuality() + 1);
|
36
|
|
- }
|
37
|
|
- }
|
38
|
|
- }
|
|
38
|
+ // combined >> if sellin < 6 and quality < 50, increase quality + 1
|
|
39
|
+ if (items[i].getSellIn() < 6) {
|
|
40
|
+ items[i].setQuality(items[i].getQuality() + 1);
|
39
|
41
|
}
|
40
|
42
|
}
|
|
43
|
+ //// END first if-else
|
|
44
|
+
|
41
|
45
|
|
|
46
|
+ //////////// second if
|
42
|
47
|
if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
43
|
48
|
items[i].setSellIn(items[i].getSellIn() - 1);
|
44
|
49
|
}
|
45
|
50
|
|
|
51
|
+
|
|
52
|
+ //////////// third if
|
46
|
53
|
if (items[i].getSellIn() < 0) {
|
47
|
|
- if (!items[i].getName().equals("Aged Brie")) {
|
48
|
|
- if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
49
|
|
- if (items[i].getQuality() > 0) {
|
50
|
|
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
51
|
|
- items[i].setQuality(items[i].getQuality() - 1);
|
52
|
|
- }
|
53
|
|
- }
|
54
|
|
- } else {
|
55
|
|
- items[i].setQuality(items[i].getQuality()
|
56
|
|
- - items[i].getQuality());
|
57
|
|
- }
|
58
|
|
- } else {
|
|
54
|
+
|
|
55
|
+ // nested if-else
|
|
56
|
+ if ((!items[i].getName().equals("Aged Brie") &&
|
|
57
|
+ !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert") &&
|
|
58
|
+ !items[i].getName().equals("Sulfuras, Hand of Ragnaros") &&
|
|
59
|
+ items[i].getQuality() > 0)) {
|
|
60
|
+ items[i].setQuality(items[i].getQuality() - 1);
|
|
61
|
+ } else if (items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
62
|
+ items[i].setQuality(0);
|
|
63
|
+ } else if (items[i].getName().equals("Aged Brie")) {
|
59
|
64
|
if (items[i].getQuality() < 50) {
|
60
|
65
|
items[i].setQuality(items[i].getQuality() + 1);
|
61
|
66
|
}
|
62
|
67
|
}
|
|
68
|
+
|
63
|
69
|
}
|
64
|
70
|
}
|
65
|
71
|
}
|