|
@@ -9,58 +9,143 @@ public class Inventory {
|
9
|
9
|
this.items = items;
|
10
|
10
|
}
|
11
|
11
|
|
|
12
|
+// public void updateQuality() {
|
|
13
|
+// //for each item in the inventory
|
|
14
|
+// for (int i = 0; i < items.length; i++) {
|
|
15
|
+//
|
|
16
|
+// //if the items name not equal aged brie and the items name does not equal Backstage passes to a TAFKAL80ETC concert and the items quality is greater than 0, and the items name does not equal Sulfuras, Hand of Ragnaros
|
|
17
|
+// if (!items[i].getName().equals("Aged Brie") && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert") && items[i].getQuality() > 0 && !items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
|
18
|
+// //decrease quality by one
|
|
19
|
+// items[i].setQuality(items[i].getQuality() - 1);
|
|
20
|
+// //if the items name is "Aged Brie", "Backstage passes to a TAFKAL80ETC concert" or "Sulfuras, Hand of Ragnaros", and the quality is between 0 and 50
|
|
21
|
+// } else if(items[i].getQuality() < 50){
|
|
22
|
+// //increase item quality by one
|
|
23
|
+// items[i].setQuality(items[i].getQuality() + 1);
|
|
24
|
+// //if the item is "Backstage passes to a TAFKAL80ETC concert" and the item sells in less than 11 days
|
|
25
|
+// if (items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert") && items[i].getSellIn() < 11) {
|
|
26
|
+// //increase item quality by one
|
|
27
|
+// items[i].setQuality(items[i].getQuality() + 1);
|
|
28
|
+// //if the item sells in less than 6 days
|
|
29
|
+// if (items[i].getSellIn() < 6) {
|
|
30
|
+// //increase item quality by another one
|
|
31
|
+// items[i].setQuality(items[i].getQuality() + 1);
|
|
32
|
+// }
|
|
33
|
+// }
|
|
34
|
+// }
|
|
35
|
+// //if the item is past its expiration date
|
|
36
|
+// if (items[i].getSellIn() < 0 ) {
|
|
37
|
+// //and it is not aged brie
|
|
38
|
+// if (!items[i].getName().equals("Aged Brie")) {
|
|
39
|
+// //if the item name is not "Backstage passes to a TAFKAL80ETC concert" and the quality is greater than 0
|
|
40
|
+// if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert") && items[i].getQuality() > 0) {
|
|
41
|
+// //if the item name is "Sulfuras, Hand of Ragnaros"
|
|
42
|
+// if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
|
43
|
+// //decrease the item quality by one
|
|
44
|
+// items[i].setQuality(items[i].getQuality() - 1);
|
|
45
|
+// }
|
|
46
|
+// //if the item is not "Backstage passes to a TAFKAL80ETC concert" and the quality is greater than 0
|
|
47
|
+// } else {
|
|
48
|
+// //set item quality to 0
|
|
49
|
+// items[i].setQuality(0);
|
|
50
|
+// }
|
|
51
|
+// //if the item is not named aged brie
|
|
52
|
+// } else {
|
|
53
|
+// //and it is less than 50 quality
|
|
54
|
+// if (items[i].getQuality() < 50) {
|
|
55
|
+// //increase the quality by one
|
|
56
|
+// items[i].setQuality(items[i].getQuality() + 1);
|
|
57
|
+// }
|
|
58
|
+// }
|
|
59
|
+// }
|
|
60
|
+// }
|
|
61
|
+// }
|
12
|
62
|
|
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
|
|
- }
|
|
63
|
+ public void updateQuality02() {
|
|
64
|
+
|
|
65
|
+ for(int i = 0; i < items.length; i ++){
|
|
66
|
+
|
|
67
|
+ switch(items[i].getName()){
|
|
68
|
+
|
|
69
|
+ case "Aged Brie":
|
|
70
|
+ increaseQuality(items[i]);
|
|
71
|
+ passedSellin(items[i]);
|
|
72
|
+ break;
|
|
73
|
+
|
|
74
|
+ case "Backstage passes to a TAFKAL80ETC concert":
|
|
75
|
+ increaseQuality(items[i]);
|
|
76
|
+ checkSellinTickets(items[i]);
|
|
77
|
+ passedSellin(items[i]);
|
|
78
|
+ break;
|
|
79
|
+
|
|
80
|
+ case "Sulfuras, Hand of Ragnaros":
|
|
81
|
+ break;
|
|
82
|
+
|
|
83
|
+ case "Conjured Item":
|
|
84
|
+ decreaseQuality(items[i]);
|
|
85
|
+ decreaseQuality(items[i]);
|
|
86
|
+ passedSellin(items[i]);
|
|
87
|
+ break;
|
|
88
|
+
|
|
89
|
+ default:
|
|
90
|
+ decreaseQuality(items[i]);
|
|
91
|
+ passedSellin(items[i]);
|
|
92
|
+ break;
|
40
|
93
|
}
|
|
94
|
+ }
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ private static void increaseQuality(Item item){
|
|
98
|
+ if(item.getQuality() < 50){
|
|
99
|
+ item.setQuality(item.getQuality() + 1);
|
|
100
|
+ }
|
|
101
|
+ }
|
41
|
102
|
|
42
|
|
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
43
|
|
- items[i].setSellIn(items[i].getSellIn() - 1);
|
|
103
|
+ private static void decreaseQuality(Item item){
|
|
104
|
+ if(item.getQuality() > 0){
|
|
105
|
+ item.setQuality(item.getQuality() -1);
|
|
106
|
+ }
|
|
107
|
+ }
|
|
108
|
+
|
|
109
|
+ private static void checkSellinTickets(Item item){
|
|
110
|
+ //if the items sell in is less then 11
|
|
111
|
+ if(item.getSellIn() < 11){
|
|
112
|
+ //decrease quality
|
|
113
|
+ increaseQuality(item);
|
|
114
|
+ //if it is also less then 6
|
|
115
|
+ if(item.getSellIn() < 6){
|
|
116
|
+ //decrease quality
|
|
117
|
+ increaseQuality(item);
|
44
|
118
|
}
|
|
119
|
+ }
|
|
120
|
+ }
|
|
121
|
+
|
|
122
|
+ private static void passedSellin(Item item){
|
|
123
|
+ switch(item.getName()) {
|
|
124
|
+ case "Aged Brie":
|
|
125
|
+ increaseQuality(item);
|
|
126
|
+ break;
|
45
|
127
|
|
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
|
|
- }
|
|
128
|
+ case "Backstage passes to a TAFKAL80ETC concert":
|
|
129
|
+ if(item.getSellIn() < 0) {
|
|
130
|
+ item.setQuality(0);
|
62
|
131
|
}
|
63
|
|
- }
|
|
132
|
+ break;
|
|
133
|
+
|
|
134
|
+ case "Conjured Item":
|
|
135
|
+ checkPassedDate(item);
|
|
136
|
+ checkPassedDate(item);
|
|
137
|
+ break;
|
|
138
|
+
|
|
139
|
+ default:
|
|
140
|
+ checkPassedDate(item);
|
|
141
|
+ break;
|
|
142
|
+ }
|
|
143
|
+ }
|
|
144
|
+
|
|
145
|
+ private static void checkPassedDate(Item item){
|
|
146
|
+ if(item.getSellIn() < 0){
|
|
147
|
+ decreaseQuality(item);
|
64
|
148
|
}
|
65
|
149
|
}
|
|
150
|
+
|
66
|
151
|
}
|