|
@@ -3,64 +3,111 @@ package com.zipcodewilmington.gildedrose;
|
3
|
3
|
|
4
|
4
|
public class Inventory {
|
5
|
5
|
private Item[] items;
|
|
6
|
+ static final String Aged = "Aged Brie";
|
|
7
|
+ static final String Backstage = "Backstage passes to a TAFKAL80ETC concert";
|
|
8
|
+ static final String Sulf = "Sulfuras,Hand of Ragnaros";
|
|
9
|
+ static final String Conj = "Conjured";
|
6
|
10
|
|
7
|
11
|
public Inventory(Item[] items) {
|
8
|
12
|
super();
|
9
|
13
|
this.items = items;
|
10
|
14
|
}
|
11
|
15
|
|
|
16
|
+ public void refactor() {
|
12
|
17
|
|
13
|
|
- public void updateQuality() {
|
14
|
18
|
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
|
|
- }
|
40
|
|
- }
|
41
|
19
|
|
42
|
|
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
|
43
|
|
- items[i].setSellIn(items[i].getSellIn() - 1);
|
|
20
|
+ switch (items[i].getName()) {
|
|
21
|
+
|
|
22
|
+ case Aged:
|
|
23
|
+ increaseQuality(items[i]);
|
|
24
|
+ under6days(items[i]);
|
|
25
|
+ expireditems(items[i]);
|
|
26
|
+ sulferus_Deduction(items[i]);
|
|
27
|
+
|
|
28
|
+ break;
|
|
29
|
+
|
|
30
|
+ case Backstage:
|
|
31
|
+ increaseQuality(items[i]);
|
|
32
|
+ extramoneyfortheconcert(items[i]);
|
|
33
|
+ sulferus_Deduction(items[i]);
|
|
34
|
+ expireditems(items[i]);
|
|
35
|
+ break;
|
|
36
|
+
|
|
37
|
+ case Sulf:
|
|
38
|
+ increaseQuality(items[i]);
|
|
39
|
+ under6days(items[i]);
|
|
40
|
+ expireditems(items[i]);
|
|
41
|
+ break;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+ case Conj:
|
|
45
|
+
|
|
46
|
+ notFromTheOriginalList(items[i]);
|
|
47
|
+ sulferus_Deduction(items[i]);
|
|
48
|
+
|
|
49
|
+ break;
|
|
50
|
+
|
|
51
|
+ default:
|
|
52
|
+
|
|
53
|
+ notFromTheOriginalList(items[i]);
|
|
54
|
+ sulferus_Deduction(items[i]);
|
44
|
55
|
}
|
|
56
|
+ }
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+ public void increaseQuality(Item item){
|
|
61
|
+
|
|
62
|
+ if(item.getQuality() < 50 ){
|
|
63
|
+ item.setQuality(item.getQuality()+1);
|
|
64
|
+
|
|
65
|
+ }
|
|
66
|
+ }
|
|
67
|
+ public void expireditems(Item item){
|
|
68
|
+
|
|
69
|
+ if(item.getSellIn()< 0) {
|
|
70
|
+ item.setQuality(0);
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ }
|
|
74
|
+ public void under6days(Item item){
|
|
75
|
+
|
|
76
|
+ if(item.getSellIn()<6 && item.getQuality()<50){
|
|
77
|
+
|
|
78
|
+ item.setQuality(item.getQuality()+1);
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ public void extramoneyfortheconcert(Item item){
|
|
84
|
+
|
|
85
|
+ if(item.getSellIn()<11 && item.getQuality()<50){
|
|
86
|
+
|
|
87
|
+ item.setQuality(item.getQuality()+1);
|
|
88
|
+
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ }
|
|
92
|
+ public void sulferus_Deduction(Item item){
|
|
93
|
+
|
|
94
|
+ if(!Sulf.equals(item)){
|
|
95
|
+
|
|
96
|
+ item.setSellIn(item.getSellIn()-1);
|
|
97
|
+
|
|
98
|
+ }
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ public void notFromTheOriginalList(Item item){
|
|
102
|
+
|
|
103
|
+ if(!item.equals(Sulf)&&!item.equals(Aged)&&!item.equals(Backstage)){
|
|
104
|
+
|
|
105
|
+ item.setQuality(item.getQuality()-2);
|
45
|
106
|
|
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
|
|
- }
|
62
|
|
- }
|
63
|
107
|
}
|
|
108
|
+
|
|
109
|
+
|
64
|
110
|
}
|
|
111
|
+
|
65
|
112
|
}
|
66
|
|
-}
|
|
113
|
+
|