Jevit Tith před 6 roky
rodič
revize
58822b28ba
2 změnil soubory, kde provedl 52 přidání a 42 odebrání
  1. binární
      .DS_Store
  2. 52
    42
      src/main/java/com/zipcodewilmington/gildedrose/Inventory.java

binární
.DS_Store Zobrazit soubor


+ 52
- 42
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java Zobrazit soubor

@@ -10,55 +10,65 @@ public class Inventory {
10 10
     }
11 11
 
12 12
 
13
-    public void updateQuality() {
14
-        for (int i = 0; i < items.length; i++) {
15
-            if (!items[i].getName().equals("Aged Brie")
16
-                    && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
17
-                if (items[i].getQuality() > 0) {
18
-                    if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
19
-                        items[i].setQuality(items[i].getQuality() - 1);
20
-                    }
21
-                }
22
-            } else {
23
-                if (items[i].getQuality() < 50) {
24
-                    items[i].setQuality(items[i].getQuality() + 1);
13
+    public void updateQuality(){
14
+        agedBrie();
15
+        sulfuras();
16
+        backstagePasses();
17
+        conjured();
18
+        normalItem();
19
+    }
20
+
21
+    public void agedBrie(){
22
+        for(int i = 0; i < items.length; i++){
23
+            if(items[i].getName().equals("Aged Brie") && items[i].getQuality() < 50) {
24
+                items[i].setQuality(items[i].getQuality() + 1);
25
+            }
26
+        }
27
+    }
25 28
 
26
-                    if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
27
-                        if (items[i].getSellIn() < 11) {
28
-                            if (items[i].getQuality() < 50) {
29
-                                items[i].setQuality(items[i].getQuality() + 1);
30
-                            }
31
-                        }
29
+    public void sulfuras(){
30
+        for(int i = 0; i < items.length; i++){
31
+            if(items[i].getName().equals("Sulfuras, Hand of Ragnaros") && items[i].getQuality() < 80){
32
+                continue;
33
+            }
34
+        }
35
+    }
32 36
 
33
-                        if (items[i].getSellIn() < 6) {
34
-                            if (items[i].getQuality() < 50) {
35
-                                items[i].setQuality(items[i].getQuality() + 1);
36
-                            }
37
-                        }
38
-                    }
37
+    public void backstagePasses(){
38
+        for(int i = 0; i < items.length; i++) {
39
+            if(items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
40
+                if(items[i].getSellIn() < 0){
41
+                    items[i].setQuality(0);
42
+                }else if(items[i].getSellIn() <= 5 && items[i].getQuality() < 48){
43
+                    items[i].setQuality(items[i].getQuality() + 3);
44
+                }else if(items[i].getSellIn() <= 10 && items[i].getQuality() < 49){
45
+                    items[i].setQuality(items[i].getQuality() + 2);
46
+                }else if(items[i].getSellIn() > 10 && items[i].getQuality() < 50){
47
+                    items[i].setQuality(items[i].getQuality() + 1);
39 48
                 }
40 49
             }
50
+        }
51
+    }
41 52
 
42
-            if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
43
-                items[i].setSellIn(items[i].getSellIn() - 1);
53
+    public void conjured(){
54
+        for(int i = 0; i < items.length; i++){
55
+            if(items[i].getName().equals("conjured")){
56
+                if(items[i].getSellIn() <= 0 && items[i].getQuality() >= 4){
57
+                    items[i].setQuality(items[i].getQuality() - 4);
58
+                } else if(items[i].getSellIn() > 0 && items[i].getQuality() >= 2){
59
+                    items[i].setQuality(items[i].getQuality() - 2);
60
+                }
44 61
             }
62
+        }
63
+    }
45 64
 
46
-            if (items[i].getSellIn() < 0) {
47
-                if (!items[i].getName().equals("Aged Brie")) {
48
-                    if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
49
-                        if (items[i].getQuality() > 0) {
50
-                            if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
51
-                                items[i].setQuality(items[i].getQuality() - 1);
52
-                            }
53
-                        }
54
-                    } else {
55
-                        items[i].setQuality(items[i].getQuality()
56
-                                - items[i].getQuality());
57
-                    }
58
-                } else {
59
-                    if (items[i].getQuality() < 50) {
60
-                        items[i].setQuality(items[i].getQuality() + 1);
61
-                    }
65
+    public void normalItem(){
66
+        for(int i = 0; i < items.length; i++){
67
+            if(items[i].getName().equals("normal")){
68
+                if(items[i].getSellIn() <= 0 && items[i].getQuality() >= 2){
69
+                    items[i].setQuality(items[i].getQuality() - 2);
70
+                } else if(items[i].getSellIn() > 0 && items[i].getQuality() >= 1){
71
+                    items[i].setQuality(items[i].getQuality() - 1);
62 72
                 }
63 73
             }
64 74
         }