Eric Foster 6 anos atrás
pai
commit
34d68ceced
1 arquivos alterados com 30 adições e 29 exclusões
  1. 30
    29
      Inventory.java

+ 30
- 29
Inventory.java Ver arquivo

@@ -43,49 +43,50 @@ public class Inventory {
43 43
                 }
44 44
             }
45 45
 
46
-            //level 1 - item type
47
-            if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
48
-                reduceSellInBy1(items[i]);
49
-            }
50
-
51
-            //level 1 - sell in date
52
-            if (items[i].getSellIn() < 0) {
53
-                //level 2 - item type
54
-                if (items[i].getName().equals("Aged Brie")) {
55
-                    //level 3 - quality
56
-                    if (items[i].getQuality() < 50) {
57
-                        increaseQualityBy1(items[i]);
58
-                    }
59
-                    //level 2 - item type
60
-                } else if (items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")){
61
-                    setQualityTo0(items[i]);
62
-                    //level 3 - item type
63
-                } else {
64
-                    //level 4 - quality
65
-                    if (items[i].getQuality() > 0) {
66
-                        //level 5 - item type
67
-                        if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
68
-                            reduceQualityBy1(items[i]);
69
-                        }
70
-                    }
71
-                }
46
+            if(!items[i].getName().equals("Sulfuras, Hand of Ragnaros")){
47
+                updateSellInDays(items[i]);
72 48
             }
49
+            updateExpiredItems(items[i]);
73 50
         }
74 51
     }
75 52
 
76 53
     public void reduceQualityBy1(Item item){
77 54
         item.setQuality(item.getQuality() -1);
78 55
     }
79
-    
56
+
80 57
     public void increaseQualityBy1(Item item){
81 58
         item.setQuality(item.getQuality() + 1);
82 59
     }
83
-    
60
+
84 61
     public void setQualityTo0(Item item){
85 62
         item.setQuality(item.getQuality() - item.getQuality());
86 63
     }
87 64
 
88
-    public void reduceSellInBy1(Item item){
65
+    public void updateSellInDays(Item item){
89 66
         item.setSellIn(item.getSellIn() - 1);
90 67
     }
68
+
69
+    public void updateExpiredItems(Item item){
70
+        if (item.getSellIn() < 0) {
71
+            //level 2 - item type
72
+            if (item.getName().equals("Aged Brie")) {
73
+                //level 3 - quality
74
+                if (item.getQuality() < 50) {
75
+                    increaseQualityBy1(item);
76
+                }
77
+                //level 2 - item type
78
+            } else if (item.getName().equals("Backstage passes to a TAFKAL80ETC concert")){
79
+                setQualityTo0(item);
80
+                //level 3 - item type
81
+            } else {
82
+                //level 4 - quality
83
+                if (item.getQuality() > 0) {
84
+                    //level 5 - item type
85
+                    if (!item.getName().equals("Sulfuras, Hand of Ragnaros")) {
86
+                        reduceQualityBy1(item);
87
+                    }
88
+                }
89
+            }
90
+        }
91
+    }
91 92
 }