|
@@ -9,58 +9,107 @@ public class Inventory {
|
9
|
9
|
this.items = items;
|
10
|
10
|
}
|
11
|
11
|
|
|
12
|
+ private void updateSellIn(Item item) {
|
|
13
|
+ item.setSellIn(item.getSellIn() - 1);
|
|
14
|
+ }
|
12
|
15
|
|
13
|
|
- public void updateQuality() {
|
14
|
|
- 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);
|
|
16
|
+ private void changeQuality(Item item, int change) {
|
|
17
|
+ item.setQuality(item.getQuality() + change);
|
|
18
|
+ }
|
25
|
19
|
|
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
|
|
- }
|
|
20
|
+ public void updateQuality() {
|
|
21
|
+ for (Item item : items) {
|
|
22
|
+ if (item.getQuality() < 50) {
|
|
23
|
+ switch (item.getName()) {
|
|
24
|
+ case "Aged Brie":
|
|
25
|
+ changeQuality(item, 1);
|
|
26
|
+ break;
|
|
27
|
+ case "Backstage passes to a TAFKAL80ETC concert":
|
|
28
|
+ if (item.getSellIn() < 6) {
|
|
29
|
+ changeQuality(item, 3);
|
|
30
|
+ } else if (item.getSellIn() < 11) {
|
|
31
|
+ changeQuality(item, 2);
|
|
32
|
+ } else {
|
|
33
|
+ changeQuality(item, 1);
|
31
|
34
|
}
|
32
|
|
-
|
33
|
|
- if (items[i].getSellIn() < 6) {
|
34
|
|
- if (items[i].getQuality() < 50) {
|
35
|
|
- items[i].setQuality(items[i].getQuality() + 1);
|
36
|
|
- }
|
|
35
|
+ break;
|
|
36
|
+ case "Sulfuras, Hand of Ragnaros":
|
|
37
|
+ continue;
|
|
38
|
+ default:
|
|
39
|
+ if (item.getSellIn() < 1) {
|
|
40
|
+ changeQuality(item, -2);
|
|
41
|
+ } else {
|
|
42
|
+ changeQuality(item, -1);
|
37
|
43
|
}
|
38
|
|
- }
|
|
44
|
+ break;
|
39
|
45
|
}
|
40
|
46
|
}
|
41
|
|
-
|
42
|
|
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
43
|
|
- items[i].setSellIn(items[i].getSellIn() - 1);
|
44
|
|
- }
|
45
|
|
-
|
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
|
|
- }
|
|
47
|
+ if (item.getQuality() < 0) {
|
|
48
|
+ item.setQuality(0);
|
63
|
49
|
}
|
|
50
|
+// default:
|
|
51
|
+// if (item.getQuality() > 0)
|
|
52
|
+// if (item.getSellIn() < 0 && item.getQuality() > 1))
|
|
53
|
+// changeQuality(item, -1);
|
|
54
|
+// if (item.getSellIn() < 0 && item.getQuality() > 1)
|
|
55
|
+// changeQuality(item, -2);
|
|
56
|
+// break;
|
|
57
|
+// }
|
|
58
|
+// }
|
|
59
|
+ updateSellIn(item);
|
64
|
60
|
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+// for (int i = 0; i < items.length; i++) {
|
|
64
|
+// if (!items[i].getName().equals("Aged Brie") && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
65
|
+// if (items[i].getQuality() > 0) {
|
|
66
|
+// if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
|
67
|
+// items[i].setQuality(items[i].getQuality() - 1);
|
|
68
|
+// }
|
|
69
|
+// }
|
|
70
|
+// } else {
|
|
71
|
+// if (items[i].getQuality() < 50 && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
72
|
+// items[i].setQuality(items[i].getQuality() + 1);
|
|
73
|
+//
|
|
74
|
+//// if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
|
|
75
|
+//// if (items[i].getSellIn() < 11) {
|
|
76
|
+//// if (items[i].getQuality() < 50) {
|
|
77
|
+//// items[i].setQuality(items[i].getQuality() + 1);
|
|
78
|
+//// }
|
|
79
|
+//// }
|
|
80
|
+////
|
|
81
|
+//// if (items[i].getSellIn() < 6) {
|
|
82
|
+//// if (items[i].getQuality() < 50) {
|
|
83
|
+//// items[i].setQuality(items[i].getQuality() + 1);
|
|
84
|
+//// }
|
|
85
|
+//// }
|
|
86
|
+//// }
|
|
87
|
+// }
|
|
88
|
+// }
|
|
89
|
+//
|
|
90
|
+// if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros") && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
91
|
+// items[i].setSellIn(items[i].getSellIn() - 1);
|
|
92
|
+// }
|
|
93
|
+//
|
|
94
|
+// if (items[i].getSellIn() < 0 && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
95
|
+// if (!items[i].getName().equals("Aged Brie")) {
|
|
96
|
+// if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
97
|
+// if (items[i].getQuality() > 0) {
|
|
98
|
+// if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
|
99
|
+// items[i].setQuality(items[i].getQuality() - 1);
|
|
100
|
+// }
|
|
101
|
+// }
|
|
102
|
+// } else {
|
|
103
|
+// items[i].setQuality(items[i].getQuality()
|
|
104
|
+// - items[i].getQuality());
|
|
105
|
+// }
|
|
106
|
+// }
|
|
107
|
+////// else {
|
|
108
|
+//////// if (items[i].getQuality() < 50) {
|
|
109
|
+//////// items[i].setQuality(items[i].getQuality() + 1);
|
|
110
|
+////// }
|
|
111
|
+//// }
|
|
112
|
+// }
|
|
113
|
+// }
|
65
|
114
|
}
|
66
|
115
|
}
|