|
@@ -22,93 +22,90 @@ public class Inventory {
|
22
|
22
|
switch (item.getName()){
|
23
|
23
|
|
24
|
24
|
case BRIE:
|
25
|
|
- if (!checkQuality(item, 1)) {
|
26
|
|
- adjustItemQuality(item, 1);
|
27
|
|
- } else {
|
28
|
|
- setQualityMax(item);
|
29
|
|
- }
|
30
|
25
|
|
31
|
|
- decreaseSellIn(item);
|
|
26
|
+ adjustItemQuality(item, 1);
|
32
|
27
|
|
|
28
|
+ decreaseSellIn(item);
|
33
|
29
|
break;
|
34
|
30
|
|
35
|
31
|
case BACK_PASS:
|
36
|
|
- if (item.getSellIn() < 0) {
|
37
|
|
- setQualityZero(item);
|
38
|
32
|
|
39
|
|
- } else if (item.getSellIn() <= 5) {
|
40
|
|
- if (!checkQuality(item, 2)) {
|
41
|
|
- adjustItemQuality(item, 2);
|
42
|
|
- } else {
|
43
|
|
- setQualityMax(item);
|
44
|
|
- }
|
45
|
|
-
|
46
|
|
- } else if (item.getSellIn() <= 10) {
|
47
|
|
- if (!checkQuality(item, 3)) {
|
48
|
|
- adjustItemQuality(item, 3);
|
49
|
|
- } else {
|
50
|
|
- setQualityMax(item);
|
51
|
|
- }
|
52
|
|
- }
|
|
33
|
+ // Check sell in because the sell in value dictates the quality modifier
|
|
34
|
+
|
|
35
|
+ if (checkPassSellIn5(item)) {
|
|
36
|
+ adjustItemQuality(item, 3);
|
|
37
|
+
|
|
38
|
+ } else if (checkPassSellIn10(item)) {
|
|
39
|
+ adjustItemQuality(item, 2);
|
53
|
40
|
|
|
41
|
+ } else if (checkPassSellInNegative(item)) {
|
|
42
|
+ setQualityZero(item);
|
|
43
|
+ } else {
|
|
44
|
+ adjustItemQuality(item, 1);
|
|
45
|
+ }
|
54
|
46
|
decreaseSellIn(item);
|
55
|
47
|
|
56
|
48
|
break;
|
57
|
49
|
|
58
|
|
-
|
59
|
50
|
case SULFURAS:
|
60
|
51
|
item.setQuality(80);
|
61
|
52
|
item.setSellIn(item.getSellIn());
|
62
|
53
|
|
63
|
|
-
|
64
|
|
-
|
65
|
|
- };
|
|
54
|
+ break;
|
|
55
|
+ }
|
66
|
56
|
}
|
67
|
57
|
}
|
68
|
58
|
|
|
59
|
+
|
69
|
60
|
public void decreaseSellIn(Item name) {
|
70
|
61
|
name.setSellIn(name.getSellIn() - 1);
|
71
|
62
|
|
72
|
63
|
}
|
73
|
64
|
|
74
|
|
- public boolean checkQuality(Item name, int addQuality) {
|
75
|
|
- boolean isQuality50 = false;
|
|
65
|
+ public boolean checkPassSellIn5(Item item) {
|
76
|
66
|
|
77
|
|
- if (name.getQuality() + addQuality < 50) {
|
78
|
|
- isQuality50 = false;
|
79
|
|
- } else {
|
80
|
|
- isQuality50 = true;
|
|
67
|
+ if (item.getSellIn() <= 5 && item.getSellIn() >= 0) {
|
|
68
|
+ return true;
|
81
|
69
|
}
|
82
|
70
|
|
83
|
|
- return isQuality50;
|
|
71
|
+ return false;
|
84
|
72
|
}
|
85
|
73
|
|
86
|
|
- public void setQualityMax(Item item) {
|
87
|
|
- item.setQuality(50);
|
88
|
|
- }
|
|
74
|
+ public boolean checkPassSellIn10(Item item) {
|
89
|
75
|
|
90
|
|
- public void setQualityZero(Item item) {
|
91
|
|
- item.setQuality(0);
|
|
76
|
+ if (item.getSellIn() <= 10 && item.getSellIn() > 5) {
|
|
77
|
+ return true;
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ return false;
|
92
|
81
|
}
|
93
|
82
|
|
|
83
|
+ public boolean checkPassSellInNegative(Item item) {
|
94
|
84
|
|
95
|
|
- public void adjustItemQuality(Item name, int qualityIncrement) {
|
|
85
|
+ if (item.getSellIn() < 0) {
|
|
86
|
+ return true;
|
|
87
|
+ }
|
96
|
88
|
|
|
89
|
+ return false;
|
97
|
90
|
}
|
98
|
91
|
|
|
92
|
+ public void setQualityMax(Item item) {
|
|
93
|
+ item.setQuality(50);
|
|
94
|
+ }
|
99
|
95
|
|
|
96
|
+ public void setQualityZero(Item item) {
|
|
97
|
+ item.setQuality(0);
|
|
98
|
+ }
|
100
|
99
|
|
|
100
|
+ public void adjustItemQuality(Item name, int qualityIncrement) {
|
101
|
101
|
|
|
102
|
+ if (name.getQuality() + qualityIncrement < 50) {
|
|
103
|
+ name.setQuality(name.getQuality() + qualityIncrement);
|
|
104
|
+ } else {
|
|
105
|
+ setQualityMax(name);
|
|
106
|
+ }
|
102
|
107
|
|
103
|
|
-// public void increaseQuality(int i){
|
104
|
|
-//
|
105
|
|
-// int quality = item.getQuality() + i;
|
106
|
|
-// if (quality > 50) {
|
107
|
|
-// quality = 50;
|
108
|
|
-// }
|
109
|
|
-//
|
110
|
|
-// item.setQuality(quality);
|
111
|
|
-// }
|
|
108
|
+ }
|
112
|
109
|
|
113
|
110
|
public Item[] getItems(){
|
114
|
111
|
return this.items;
|