|
@@ -7,28 +7,35 @@ public class Inventory {
|
7
|
7
|
this.items = items;
|
8
|
8
|
}
|
9
|
9
|
|
10
|
|
-
|
11
|
10
|
public void updateQuality() {
|
12
|
11
|
for (int i = 0; i < items.length; i++) {
|
|
12
|
+ //level 1 - item type
|
13
|
13
|
if (!items[i].getName().equals("Aged Brie")
|
14
|
|
- && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
14
|
+ && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
15
|
+ //level 2 - quality
|
15
|
16
|
if (items[i].getQuality() > 0) {
|
|
17
|
+ //level 3 - item type
|
16
|
18
|
if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
17
|
19
|
items[i].setQuality(items[i].getQuality() - 1);
|
18
|
20
|
}
|
19
|
21
|
}
|
|
22
|
+ //level 1 - item type
|
20
|
23
|
} else {
|
|
24
|
+ //level 2 - quality
|
21
|
25
|
if (items[i].getQuality() < 50) {
|
22
|
26
|
items[i].setQuality(items[i].getQuality() + 1);
|
23
|
|
-
|
|
27
|
+ //level 3 - item type
|
24
|
28
|
if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
|
|
29
|
+ //level 4 - sell in date
|
25
|
30
|
if (items[i].getSellIn() < 11) {
|
|
31
|
+ //level 5 - quality
|
26
|
32
|
if (items[i].getQuality() < 50) {
|
27
|
33
|
items[i].setQuality(items[i].getQuality() + 1);
|
28
|
34
|
}
|
29
|
35
|
}
|
30
|
|
-
|
|
36
|
+ //level 4 - sell in date
|
31
|
37
|
if (items[i].getSellIn() < 6) {
|
|
38
|
+ //level 5 - quality
|
32
|
39
|
if (items[i].getQuality() < 50) {
|
33
|
40
|
items[i].setQuality(items[i].getQuality() + 1);
|
34
|
41
|
}
|
|
@@ -36,29 +43,43 @@ public class Inventory {
|
36
|
43
|
}
|
37
|
44
|
}
|
38
|
45
|
}
|
39
|
|
-
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+ //level 1 - item type
|
40
|
49
|
if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
41
|
50
|
items[i].setSellIn(items[i].getSellIn() - 1);
|
42
|
51
|
}
|
43
|
|
-
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+ //level 1 - sell in date
|
44
|
55
|
if (items[i].getSellIn() < 0) {
|
|
56
|
+ //level 2 - item type
|
45
|
57
|
if (!items[i].getName().equals("Aged Brie")) {
|
|
58
|
+ //level 3 - item type
|
46
|
59
|
if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
|
|
60
|
+ //level 4 - quality
|
47
|
61
|
if (items[i].getQuality() > 0) {
|
|
62
|
+ //level 5 - item type
|
48
|
63
|
if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
49
|
|
- items[i].setQuality(items[i].getQuality() - 1);
|
|
64
|
+ updateQuality(items[i], -1);
|
50
|
65
|
}
|
51
|
66
|
}
|
|
67
|
+ //level 3 - item type
|
52
|
68
|
} else {
|
53
|
|
- items[i].setQuality(items[i].getQuality()
|
54
|
|
- - items[i].getQuality());
|
|
69
|
+ updateQuality(items[i], -items[i].getQuality());
|
55
|
70
|
}
|
|
71
|
+ //level 2 - item type
|
56
|
72
|
} else {
|
|
73
|
+ //level 3 - quality
|
57
|
74
|
if (items[i].getQuality() < 50) {
|
58
|
|
- items[i].setQuality(items[i].getQuality() + 1);
|
|
75
|
+ updateQuality(items[i], 1);
|
59
|
76
|
}
|
60
|
77
|
}
|
61
|
78
|
}
|
62
|
79
|
}
|
63
|
|
-}
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ public void updateQuality(Item item, int amount){
|
|
83
|
+ item.setQuality(item.getQuality() + amount);
|
|
84
|
+ }
|
64
|
85
|
}
|