Browse Source

code clean up changes.

Xcuello 6 years ago
parent
commit
ea287d33ef
1 changed files with 18 additions and 4 deletions
  1. 18
    4
      src/main/java/com/zipcodewilmington/gildedrose/Inventory.java

+ 18
- 4
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java View File

2
 
2
 
3
 
3
 
4
 public class Inventory {
4
 public class Inventory {
5
-    private Item[] items;
5
+    private static Item[] items;
6
 
6
 
7
     public Inventory(Item[] items) {
7
     public Inventory(Item[] items) {
8
+
8
         super();
9
         super();
9
         this.items = items;
10
         this.items = items;
10
     }
11
     }
11
 
12
 
12
 
13
 
13
-    public void updateQuality() {
14
+    public static void updateQuality() {
15
+
14
         for (int i = 0; i < items.length; i++) {
16
         for (int i = 0; i < items.length; i++) {
17
+
15
             if (!items[i].getName().equals("Aged Brie")
18
             if (!items[i].getName().equals("Aged Brie")
16
                     && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
19
                     && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
20
+
17
                 if (items[i].getQuality() > 0) {
21
                 if (items[i].getQuality() > 0) {
22
+
18
                     if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
23
                     if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
19
                         items[i].setQuality(items[i].getQuality() - 1);
24
                         items[i].setQuality(items[i].getQuality() - 1);
20
                     }
25
                     }
21
                 }
26
                 }
22
             } else {
27
             } else {
28
+
23
                 if (items[i].getQuality() < 50) {
29
                 if (items[i].getQuality() < 50) {
24
                     items[i].setQuality(items[i].getQuality() + 1);
30
                     items[i].setQuality(items[i].getQuality() + 1);
25
 
31
 
26
                     if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
32
                     if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
33
+
27
                         if (items[i].getSellIn() < 11) {
34
                         if (items[i].getSellIn() < 11) {
35
+
28
                             if (items[i].getQuality() < 50) {
36
                             if (items[i].getQuality() < 50) {
29
                                 items[i].setQuality(items[i].getQuality() + 1);
37
                                 items[i].setQuality(items[i].getQuality() + 1);
30
                             }
38
                             }
31
                         }
39
                         }
32
 
40
 
33
                         if (items[i].getSellIn() < 6) {
41
                         if (items[i].getSellIn() < 6) {
42
+
34
                             if (items[i].getQuality() < 50) {
43
                             if (items[i].getQuality() < 50) {
35
                                 items[i].setQuality(items[i].getQuality() + 1);
44
                                 items[i].setQuality(items[i].getQuality() + 1);
36
                             }
45
                             }
44
             }
53
             }
45
 
54
 
46
             if (items[i].getSellIn() < 0) {
55
             if (items[i].getSellIn() < 0) {
56
+
47
                 if (!items[i].getName().equals("Aged Brie")) {
57
                 if (!items[i].getName().equals("Aged Brie")) {
58
+
48
                     if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
59
                     if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
60
+
49
                         if (items[i].getQuality() > 0) {
61
                         if (items[i].getQuality() > 0) {
62
+
50
                             if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
63
                             if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
51
                                 items[i].setQuality(items[i].getQuality() - 1);
64
                                 items[i].setQuality(items[i].getQuality() - 1);
52
                             }
65
                             }
53
                         }
66
                         }
54
                     } else {
67
                     } else {
55
-                        items[i].setQuality(items[i].getQuality()
56
-                                - items[i].getQuality());
68
+
69
+                        items[i].setQuality(0);
57
                     }
70
                     }
58
                 } else {
71
                 } else {
72
+
59
                     if (items[i].getQuality() < 50) {
73
                     if (items[i].getQuality() < 50) {
60
                         items[i].setQuality(items[i].getQuality() + 1);
74
                         items[i].setQuality(items[i].getQuality() + 1);
61
                     }
75
                     }