Przeglądaj źródła

code clean up changes.

Xcuello 6 lat temu
rodzic
commit
ea287d33ef

+ 18
- 4
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java Wyświetl plik

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