|
@@ -9,58 +9,150 @@ public class Inventory {
|
9
|
9
|
this.items = items;
|
10
|
10
|
}
|
11
|
11
|
|
12
|
|
-
|
13
|
|
- public void updateQuality() {
|
|
12
|
+ public void qualityUpdate() {
|
14
|
13
|
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) {
|
24
|
|
- items[i].setQuality(items[i].getQuality() + 1);
|
25
|
|
-
|
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
|
|
- }
|
|
14
|
+
|
|
15
|
+ switch (items[i].getName()) {
|
|
16
|
+
|
|
17
|
+ case "A book":
|
|
18
|
+ if (items[i].getQuality() > 0) {
|
|
19
|
+ items[i].setQuality(items[i].getQuality() - 2);
|
|
20
|
+ break;
|
38
|
21
|
}
|
39
|
|
- }
|
|
22
|
+
|
|
23
|
+ case "Aged Brie":
|
|
24
|
+ increaseQuality(items[i]);
|
|
25
|
+ increaseQuality(items[i]);
|
|
26
|
+ break;
|
|
27
|
+
|
|
28
|
+ case "Backstage passes to a TAFKAL80ETC concert":
|
|
29
|
+ increaseQuality(items[i]);
|
|
30
|
+ checkSellIn(items[i]);
|
|
31
|
+ overSellIn(items[i]);
|
|
32
|
+ break;
|
|
33
|
+
|
|
34
|
+ case "Sulfuras, Hand of Ragnaros":
|
|
35
|
+ break;
|
|
36
|
+
|
|
37
|
+ case "Conjuring":
|
|
38
|
+ decreaseQuality(items[i]);
|
|
39
|
+ items[i].setQuality(items[i].getQuality() - 3);
|
|
40
|
+ overSellIn(items[i]);
|
|
41
|
+ break;
|
|
42
|
+
|
|
43
|
+ default:
|
|
44
|
+ decreaseQuality(items[i]);
|
|
45
|
+ checkOverSellIn(items[i]);
|
|
46
|
+
|
40
|
47
|
}
|
41
|
48
|
|
42
|
|
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
43
|
|
- items[i].setSellIn(items[i].getSellIn() - 1);
|
|
49
|
+ }
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+ public static void increaseQuality(Item item){
|
|
54
|
+ if (item.getQuality() < 50) {
|
|
55
|
+ item.setQuality(item.getQuality() + 1);
|
|
56
|
+
|
44
|
57
|
}
|
|
58
|
+ }
|
|
59
|
+ public static void decreaseQuality(Item item){
|
|
60
|
+ if (item.getQuality() > 0) {
|
|
61
|
+ item.setQuality(item.getQuality() - 1);
|
45
|
62
|
|
46
|
|
- 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 {
|
59
|
|
- if (items[i].getQuality() < 50) {
|
60
|
|
- items[i].setQuality(items[i].getQuality() + 1);
|
61
|
|
- }
|
62
|
|
- }
|
63
|
63
|
}
|
64
|
64
|
}
|
|
65
|
+
|
|
66
|
+ public static void checkSellIn(Item item) {
|
|
67
|
+ if (item.getSellIn() < 11) {
|
|
68
|
+ increaseQuality(item);
|
|
69
|
+ }
|
|
70
|
+ if (item.getSellIn() < 6) {
|
|
71
|
+ increaseQuality(item);
|
|
72
|
+ }
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ public static void checkOverSellIn(Item item){
|
|
76
|
+ if (item.getQuality() < 0) {
|
|
77
|
+ decreaseQuality(item);
|
|
78
|
+ }
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ public static void overSellIn(Item item){
|
|
82
|
+ switch (item.getName()) {
|
|
83
|
+ case "Aged Brie":
|
|
84
|
+ increaseQuality(item);
|
|
85
|
+ break;
|
|
86
|
+
|
|
87
|
+ case "Backstage passes to a TAFKAL80ETC concert":
|
|
88
|
+ if(item.getQuality() < 0) {
|
|
89
|
+ item.setQuality(0);
|
|
90
|
+ }
|
|
91
|
+ break;
|
|
92
|
+
|
|
93
|
+ case "Conjuring":
|
|
94
|
+ checkOverSellIn(item);
|
|
95
|
+ break;
|
|
96
|
+
|
|
97
|
+ default:
|
|
98
|
+ checkOverSellIn(item);
|
|
99
|
+ break;
|
|
100
|
+ }
|
|
101
|
+
|
|
102
|
+
|
65
|
103
|
}
|
|
104
|
+
|
|
105
|
+// public void updateQuality() {
|
|
106
|
+// for (int i = 0; i < items.length; i++) {
|
|
107
|
+// if (!items[i].getName().equals("Aged Brie")
|
|
108
|
+// && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
109
|
+// if (items[i].getQuality() > 0) {
|
|
110
|
+// if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
|
111
|
+// items[i].setQuality(items[i].getQuality() - 1);
|
|
112
|
+// }
|
|
113
|
+// }
|
|
114
|
+// } else {
|
|
115
|
+// if (items[i].getQuality() < 50) {
|
|
116
|
+// items[i].setQuality(items[i].getQuality() + 1);
|
|
117
|
+//
|
|
118
|
+// if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
|
|
119
|
+// if (items[i].getSellIn() < 11) {
|
|
120
|
+// if (items[i].getQuality() < 50) {
|
|
121
|
+// items[i].setQuality(items[i].getQuality() + 1);
|
|
122
|
+// }
|
|
123
|
+// }
|
|
124
|
+//
|
|
125
|
+// if (items[i].getSellIn() < 6) {
|
|
126
|
+// if (items[i].getQuality() < 50) {
|
|
127
|
+// items[i].setQuality(items[i].getQuality() + 1);
|
|
128
|
+// }
|
|
129
|
+// }
|
|
130
|
+// }
|
|
131
|
+// }
|
|
132
|
+// }
|
|
133
|
+//
|
|
134
|
+// if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
|
135
|
+// items[i].setSellIn(items[i].getSellIn() - 1);
|
|
136
|
+// }
|
|
137
|
+//
|
|
138
|
+// if (items[i].getSellIn() < 0) {
|
|
139
|
+// if (!items[i].getName().equals("Aged Brie")) {
|
|
140
|
+// if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
141
|
+// if (items[i].getQuality() > 0) {
|
|
142
|
+// if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
|
143
|
+// items[i].setQuality(items[i].getQuality() - 1);
|
|
144
|
+// }
|
|
145
|
+// }
|
|
146
|
+// } else {
|
|
147
|
+// items[i].setQuality(items[i].getQuality()
|
|
148
|
+// - items[i].getQuality());
|
|
149
|
+// }
|
|
150
|
+// } else {
|
|
151
|
+// if (items[i].getQuality() < 50) {
|
|
152
|
+// items[i].setQuality(items[i].getQuality() + 1);
|
|
153
|
+// }
|
|
154
|
+// }
|
|
155
|
+// }
|
|
156
|
+// }
|
|
157
|
+// }
|
66
|
158
|
}
|