Eric Foster 6 years ago
parent
commit
d9d61a8f5b
1 changed files with 13 additions and 10 deletions
  1. 13
    10
      Inventory.java

+ 13
- 10
Inventory.java View File

@@ -22,22 +22,25 @@ public class Inventory {
22 22
     }
23 23
 
24 24
     public void updateQuality(Item item){
25
-        if (item.getName().equals("Aged Brie")){
26
-            if (item.getQuality() < 50) {
27
-                increaseQualityBy1(item);
28
-            }
29
-        } else if (item.getName().equals("Backstage passes to a TAFKAL80ETC concert")){
30
-            if (item.getQuality() < 50) {
31
-                increaseQualityBy1(item);
32
-            }
25
+        if (item.getName().equals("Aged Brie") || 
26
+        item.getName().equals("Backstage passes to a TAFKAL80ETC concert")){
27
+            updateQualityForAgedItems(item);
28
+        } else if (item.getQuality() > 0) {
29
+            reduceQualityBy1(item);
30
+        }
31
+    }
32
+
33
+    public void updateQualityForAgedItems(Item item){
34
+        if (item.getQuality() < 50) {
35
+            increaseQualityBy1(item);
36
+        }
37
+        if (item.getName().equals("Backstage passes to a TAFKAL80ETC concert")){
33 38
             if (item.getSellIn() < 11 && item.getQuality() < 50) {
34 39
                 increaseQualityBy1(item);
35 40
             }
36 41
             if (item.getSellIn() < 6 && item.getQuality() < 50) {
37 42
                 increaseQualityBy1(item);
38 43
             }
39
-        } else if (item.getQuality() > 0) {
40
-            reduceQualityBy1(item);
41 44
         }
42 45
     }
43 46