Eric Foster před 6 roky
rodič
revize
d0948950bd
1 změnil soubory, kde provedl 19 přidání a 13 odebrání
  1. 19
    13
      Inventory.java

+ 19
- 13
Inventory.java Zobrazit soubor

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