Przeglądaj źródła

minor refactoring

mpierse 6 lat temu
rodzic
commit
876224aba8

+ 11
- 16
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java Wyświetl plik

@@ -13,27 +13,23 @@ public class Inventory {
13 13
     public void updateQuality() {
14 14
         for (int i = 0; i < items.length; i++) {
15 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
-                }
16
+                    && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")
17
+                    && !items[i].getName().equals("Sulfuras, Hand of Ragnaros")
18
+                    && items[i].getQuality() > 0) {
19
+                items[i].setQuality(items[i].getQuality() - 1);
20
+
21
+
22 22
             } else {
23
+
23 24
                 if (items[i].getQuality() < 50) {
24 25
                     items[i].setQuality(items[i].getQuality() + 1);
25 26
 
26
-                    if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
27
+                    if (items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
27 28
                         if (items[i].getSellIn() < 11) {
28
-                            if (items[i].getQuality() < 50) {
29 29
                                 items[i].setQuality(items[i].getQuality() + 1);
30
-                            }
31 30
                         }
32
-
33
-                        if (items[i].getSellIn() < 6) {
34
-                            if (items[i].getQuality() < 50) {
31
+                        if (items[i].getSellIn() < 6 && items[i].getQuality() < 50) {
35 32
                                 items[i].setQuality(items[i].getQuality() + 1);
36
-                            }
37 33
                         }
38 34
                     }
39 35
                 }
@@ -52,8 +48,7 @@ public class Inventory {
52 48
                             }
53 49
                         }
54 50
                     } else {
55
-                        items[i].setQuality(items[i].getQuality()
56
-                                - items[i].getQuality());
51
+                        items[i].setQuality(0);
57 52
                     }
58 53
                 } else {
59 54
                     if (items[i].getQuality() < 50) {
@@ -63,4 +58,4 @@ public class Inventory {
63 58
             }
64 59
         }
65 60
     }
66
-}
61
+}