|
@@ -9,31 +9,74 @@ public class Inventory {
|
9
|
9
|
|
10
|
10
|
public void updateQuality() {
|
11
|
11
|
for (int i = 0; i < items.length; i++) {
|
|
12
|
+
|
|
13
|
+ if (items[i].getName().equals("Sulfuras, Hand of Ragnaros")){
|
|
14
|
+ continue;
|
|
15
|
+ }
|
|
16
|
+ else if (items[i].getName().equals("Aged Brie")){
|
|
17
|
+ agedBrieUpdate(i);
|
|
18
|
+ }
|
|
19
|
+ else {
|
|
20
|
+ regularItemUpdate(i);
|
|
21
|
+ }
|
|
22
|
+
|
|
23
|
+ /*
|
12
|
24
|
if (!items[i].getName().equals("Aged Brie")) {
|
13
|
|
- if (items[i].getQuality() > 0) {
|
14
|
|
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
15
|
|
- items[i].setQuality(items[i].getQuality() - 1);
|
16
|
|
- }
|
17
|
|
- }
|
|
25
|
+ if (items[i].getQuality() > 0) {
|
|
26
|
+ if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
|
27
|
+ items[i].setQuality(items[i].getQuality() - 1);
|
|
28
|
+ }
|
|
29
|
+ }
|
18
|
30
|
} else {
|
19
|
|
- if (items[i].getQuality() < 50) {
|
20
|
|
- items[i].setQuality(items[i].getQuality() + 1);
|
21
|
|
- }
|
|
31
|
+ if (items[i].getQuality() < 50) {
|
|
32
|
+ items[i].setQuality(items[i].getQuality() + 1);
|
|
33
|
+ }
|
22
|
34
|
}
|
23
|
35
|
|
24
|
36
|
if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
25
|
|
- items[i].setSellIn(items[i].getSellIn() - 1);
|
|
37
|
+ items[i].setSellIn(items[i].getSellIn() - 1);
|
26
|
38
|
}
|
27
|
39
|
|
28
|
40
|
if (items[i].getSellIn() < 0) {
|
29
|
|
- if (!items[i].getName().equals("Aged Brie")) {
|
30
|
|
- items[i].setQuality(items[i].getQuality() - 1);
|
31
|
|
- } else {
|
32
|
|
- if (items[i].getQuality() < 50) {
|
33
|
|
- items[i].setQuality(items[i].getQuality() + 1);
|
34
|
|
- }
|
35
|
|
- }
|
|
41
|
+ if (!items[i].getName().equals("Aged Brie")) {
|
|
42
|
+ items[i].setQuality(items[i].getQuality() - 1);
|
|
43
|
+ } else {
|
|
44
|
+ if (items[i].getQuality() < 50) {
|
|
45
|
+ items[i].setQuality(items[i].getQuality() + 1);
|
|
46
|
+ }
|
36
|
47
|
}
|
|
48
|
+ }
|
|
49
|
+ */
|
37
|
50
|
}
|
38
|
|
-}
|
39
|
|
-}
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ public void agedBrieUpdate(int i){
|
|
54
|
+ //decrease the sellin by 1 every day
|
|
55
|
+ items[i].setSellIn(items[i].getSellIn()-1);
|
|
56
|
+
|
|
57
|
+ //increase the quality every day (as long as quality is not more than 50)
|
|
58
|
+ //increase the quality by 1 if sellin is greater than 0 and by 2 if sellin is 0
|
|
59
|
+ if (items[i].getSellIn() > 0 && items[i].getQuality() < 50)
|
|
60
|
+ items[i].setQuality(items[i].getQuality()+1);
|
|
61
|
+ else if (items[i].getSellIn() <= 0 && (items[i].getQuality() < 49))
|
|
62
|
+ items[i].setQuality(items[i].getQuality()+2);
|
|
63
|
+ else if (items[i].getSellIn() <= 0 && items[i].getQuality() == 49)
|
|
64
|
+ items[i].setQuality(items[i].getQuality()+1);
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ public void regularItemUpdate(int i){
|
|
68
|
+ //decrease the sellin by 1 every day
|
|
69
|
+ items[i].setSellIn(items[i].getSellIn()-1);
|
|
70
|
+
|
|
71
|
+ //decrease the quality every day (as long as quality is greater than 0)
|
|
72
|
+ //decrease the quality by 1 if sellin is greater than 0 and by 2 if sellin is 0
|
|
73
|
+ if (items[i].getQuality() > 0){
|
|
74
|
+ if (items[i].getSellIn() > 0){
|
|
75
|
+ items[i].setQuality(items[i].getQuality() -1);
|
|
76
|
+ }
|
|
77
|
+ else {
|
|
78
|
+ items[i].setQuality(items[i].getQuality() -2);
|
|
79
|
+ }
|
|
80
|
+ }
|
|
81
|
+ }
|
|
82
|
+}
|