|
@@ -9,58 +9,92 @@ public class Inventory {
|
9
|
9
|
this.items = items;
|
10
|
10
|
}
|
11
|
11
|
|
|
12
|
+ public void updateQuality02() {
|
12
|
13
|
|
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);
|
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
|
|
- }
|
38
|
|
- }
|
39
|
|
- }
|
|
14
|
+ for(int i = 0; i < items.length; i ++){
|
|
15
|
+
|
|
16
|
+ switch(items[i].getName()){
|
|
17
|
+
|
|
18
|
+ case "Aged Brie":
|
|
19
|
+ increaseQuality(items[i]);
|
|
20
|
+ passedSellin(items[i]);
|
|
21
|
+ break;
|
|
22
|
+
|
|
23
|
+ case "Backstage passes to a TAFKAL80ETC concert":
|
|
24
|
+ increaseQuality(items[i]);
|
|
25
|
+ checkSellinTickets(items[i]);
|
|
26
|
+ passedSellin(items[i]);
|
|
27
|
+ break;
|
|
28
|
+
|
|
29
|
+ case "Sulfuras, Hand of Ragnaros":
|
|
30
|
+ break;
|
|
31
|
+
|
|
32
|
+ case "Conjured Item":
|
|
33
|
+ decreaseQuality(items[i]);
|
|
34
|
+ decreaseQuality(items[i]);
|
|
35
|
+ passedSellin(items[i]);
|
|
36
|
+ break;
|
|
37
|
+
|
|
38
|
+ default:
|
|
39
|
+ decreaseQuality(items[i]);
|
|
40
|
+ passedSellin(items[i]);
|
|
41
|
+ break;
|
40
|
42
|
}
|
|
43
|
+ }
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ private static void increaseQuality(Item item){
|
|
47
|
+ if(item.getQuality() < 50){
|
|
48
|
+ item.setQuality(item.getQuality() + 1);
|
|
49
|
+ }
|
|
50
|
+ }
|
41
|
51
|
|
42
|
|
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
43
|
|
- items[i].setSellIn(items[i].getSellIn() - 1);
|
|
52
|
+ private static void decreaseQuality(Item item){
|
|
53
|
+ if(item.getQuality() > 0){
|
|
54
|
+ item.setQuality(item.getQuality() -1);
|
|
55
|
+ }
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ private static void checkSellinTickets(Item item){
|
|
59
|
+ //if the items sell in is less then 11
|
|
60
|
+ if(item.getSellIn() < 11){
|
|
61
|
+ //decrease quality
|
|
62
|
+ increaseQuality(item);
|
|
63
|
+ //if it is also less then 6
|
|
64
|
+ if(item.getSellIn() < 6){
|
|
65
|
+ //decrease quality
|
|
66
|
+ increaseQuality(item);
|
44
|
67
|
}
|
|
68
|
+ }
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ private static void passedSellin(Item item){
|
|
72
|
+ switch(item.getName()) {
|
|
73
|
+ case "Aged Brie":
|
|
74
|
+ increaseQuality(item);
|
|
75
|
+ break;
|
45
|
76
|
|
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
|
|
- }
|
|
77
|
+ case "Backstage passes to a TAFKAL80ETC concert":
|
|
78
|
+ if(item.getSellIn() < 0) {
|
|
79
|
+ item.setQuality(0);
|
62
|
80
|
}
|
63
|
|
- }
|
|
81
|
+ break;
|
|
82
|
+
|
|
83
|
+ case "Conjured Item":
|
|
84
|
+ checkPassedDate(item);
|
|
85
|
+ checkPassedDate(item);
|
|
86
|
+ break;
|
|
87
|
+
|
|
88
|
+ default:
|
|
89
|
+ checkPassedDate(item);
|
|
90
|
+ break;
|
|
91
|
+ }
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ private static void checkPassedDate(Item item){
|
|
95
|
+ if(item.getSellIn() < 0){
|
|
96
|
+ decreaseQuality(item);
|
64
|
97
|
}
|
65
|
98
|
}
|
|
99
|
+
|
66
|
100
|
}
|