Eric Foster 6 年之前
父節點
當前提交
dc5b3124ef
共有 1 個檔案被更改,包括 27 行新增45 行删除
  1. 27
    45
      Inventory.java

+ 27
- 45
Inventory.java 查看文件

@@ -9,41 +9,35 @@ public class Inventory {
9 9
 
10 10
     public void updateQuality() {
11 11
         for (int i = 0; i < items.length; i++) {
12
-            if (items[i].getName().equals("Aged Brie")
13
-            || items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
14
-                //level 2 - quality
15
-                if (items[i].getQuality() < 50) {
16
-                    increaseQualityBy1(items[i]);
17
-                    //level 3 - item type
18
-                    if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
19
-                        //level 4 - sell in date
20
-                        if (items[i].getSellIn() < 11) {
21
-                            //level 5 - quality
22
-                            if (items[i].getQuality() < 50) {
23
-                                increaseQualityBy1(items[i]);
12
+            if(!items[i].getName().equals("Sulfuras, Hand of Ragnaros")){
13
+                if (items[i].getName().equals("Aged Brie")
14
+                || items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
15
+                    //level 2 - quality
16
+                    if (items[i].getQuality() < 50) {
17
+                        increaseQualityBy1(items[i]);
18
+                        //level 3 - item type
19
+                        if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
20
+                            //level 4 - sell in date
21
+                            if (items[i].getSellIn() < 11) {
22
+                                //level 5 - quality
23
+                                if (items[i].getQuality() < 50) {
24
+                                    increaseQualityBy1(items[i]);
25
+                                }
24 26
                             }
25
-                        }
26
-                        //level 4 - sell in date
27
-                        if (items[i].getSellIn() < 6) {
28
-                            //level 5 - quality
29
-                            if (items[i].getQuality() < 50) {
30
-                                increaseQualityBy1(items[i]);
27
+                            //level 4 - sell in date
28
+                            if (items[i].getSellIn() < 6) {
29
+                                //level 5 - quality
30
+                                if (items[i].getQuality() < 50) {
31
+                                    increaseQualityBy1(items[i]);
32
+                                }
31 33
                             }
32 34
                         }
33 35
                     }
36
+                    //level 1 - item type
37
+                } else if (items[i].getQuality() > 0) {
38
+                    reduceQualityBy1(items[i]);
34 39
                 }
35
-                //level 1 - item type
36
-            } else {
37
-                //level 2 - quality
38
-                if (items[i].getQuality() > 0) {
39
-                    //level 3 - item type
40
-                    if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
41
-                        reduceQualityBy1(items[i]);
42
-                    }
43
-                }
44
-            }
45 40
 
46
-            if(!items[i].getName().equals("Sulfuras, Hand of Ragnaros")){
47 41
                 updateSellInDays(items[i]);
48 42
                 if (items[i].getSellIn() < 0) {
49 43
                     updateExpiredItems(items[i]);
@@ -69,24 +63,12 @@ public class Inventory {
69 63
     }
70 64
 
71 65
     public void updateExpiredItems(Item item){
72
-        //level 1 - item type
73
-        if (item.getName().equals("Aged Brie")) {
74
-            //level 2 - quality
75
-            if (item.getQuality() < 50) {
76
-                increaseQualityBy1(item);
77
-            }
78
-            //level 1 - item type
66
+        if (item.getName().equals("Aged Brie") && item.getQuality() < 50) {
67
+            increaseQualityBy1(item);
79 68
         } else if (item.getName().equals("Backstage passes to a TAFKAL80ETC concert")){
80 69
             setQualityTo0(item);
81
-            //level 1 - item type
82
-        } else {
83
-            //level 2 - quality
84
-            if (item.getQuality() > 0) {
85
-                //level 3 - item type
86
-
87
-                reduceQualityBy1(item);
88
-
89
-            }
70
+        } else if (item.getQuality() > 0) {
71
+            reduceQualityBy1(item);
90 72
         }
91 73
     }
92 74
 }