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

+ 19
- 13
Inventory.java View File

13
             || items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
13
             || items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
14
                 //level 2 - quality
14
                 //level 2 - quality
15
                 if (items[i].getQuality() < 50) {
15
                 if (items[i].getQuality() < 50) {
16
-                    updateQuality(items[i], 1);
16
+                    increaseQualityBy1(items[i]);
17
                     //level 3 - item type
17
                     //level 3 - item type
18
                     if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
18
                     if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
19
                         //level 4 - sell in date
19
                         //level 4 - sell in date
20
                         if (items[i].getSellIn() < 11) {
20
                         if (items[i].getSellIn() < 11) {
21
                             //level 5 - quality
21
                             //level 5 - quality
22
                             if (items[i].getQuality() < 50) {
22
                             if (items[i].getQuality() < 50) {
23
-                                updateQuality(items[i], 1);
23
+                                increaseQualityBy1(items[i]);
24
                             }
24
                             }
25
                         }
25
                         }
26
                         //level 4 - sell in date
26
                         //level 4 - sell in date
27
                         if (items[i].getSellIn() < 6) {
27
                         if (items[i].getSellIn() < 6) {
28
                             //level 5 - quality
28
                             //level 5 - quality
29
                             if (items[i].getQuality() < 50) {
29
                             if (items[i].getQuality() < 50) {
30
-                                updateQuality(items[i], 1);
30
+                                increaseQualityBy1(items[i]);
31
                             }
31
                             }
32
                         }
32
                         }
33
                     }
33
                     }
38
                 if (items[i].getQuality() > 0) {
38
                 if (items[i].getQuality() > 0) {
39
                     //level 3 - item type
39
                     //level 3 - item type
40
                     if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
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
             //level 1 - item type
46
             //level 1 - item type
47
             if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
47
             if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
48
-                updateSellIn(items[i]);
48
+                reduceSellInBy1(items[i]);
49
             }
49
             }
50
 
50
 
51
             //level 1 - sell in date
51
             //level 1 - sell in date
54
                 if (items[i].getName().equals("Aged Brie")) {
54
                 if (items[i].getName().equals("Aged Brie")) {
55
                     //level 3 - quality
55
                     //level 3 - quality
56
                     if (items[i].getQuality() < 50) {
56
                     if (items[i].getQuality() < 50) {
57
-                        updateQuality(items[i], 1);
57
+                        increaseQualityBy1(items[i]);
58
                     }
58
                     }
59
                     //level 2 - item type
59
                     //level 2 - item type
60
                 } else if (items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")){
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
                     //level 3 - item type
62
                     //level 3 - item type
65
                 } else {
63
                 } else {
66
                     //level 4 - quality
64
                     //level 4 - quality
67
                     if (items[i].getQuality() > 0) {
65
                     if (items[i].getQuality() > 0) {
68
                         //level 5 - item type
66
                         //level 5 - item type
69
                         if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
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
         }
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
         item.setSellIn(item.getSellIn() - 1);
89
         item.setSellIn(item.getSellIn() - 1);
84
     }
90
     }
85
 }
91
 }