Browse Source

completed lab

Christian Sheridan 6 years ago
parent
commit
14745cc85c

+ 22
- 40
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java View File

@@ -13,53 +13,35 @@ public class Inventory {
13 13
     public void updateQuality() {
14 14
         for (int i = 0; i < items.length; i++) {
15 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);
25
-
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
-                        }
16
+                    && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert") && items[i].getQuality() > 0
17
+                    && !items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
18
+                items[i].setQuality(items[i].getQuality() - 1);
19
+            }
20
+            if (items[i].getQuality() < 50) {
21
+                items[i].setQuality(items[i].getQuality() + 1);
22
+            }
32 23
 
33
-                        if (items[i].getSellIn() < 6) {
34
-                            if (items[i].getQuality() < 50) {
35
-                                items[i].setQuality(items[i].getQuality() + 1);
36
-                            }
37
-                        }
38
-                    }
39
-                }
24
+            if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert" && items[i].getSellIn() < 11
25
+                    && items[i].getQuality() < 50) {
26
+                items[i].setQuality(items[i].getQuality() + 1);
27
+            }
28
+            if (items[i].getSellIn() < 6 && items[i].getQuality() < 50) {
29
+                items[i].setQuality(items[i].getQuality() + 1);
40 30
             }
41 31
 
42 32
             if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
43 33
                 items[i].setSellIn(items[i].getSellIn() - 1);
44 34
             }
45 35
 
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
-                    }
62
-                }
36
+            if (items[i].getSellIn() < 0 && !items[i].getName().equals("Aged Brie") &&
37
+                    !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert") && items[i].getQuality() > 0
38
+                    && !items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
39
+                items[i].setQuality(items[i].getQuality() - 1);
40
+            } else {
41
+                items[i].setQuality(items[i].getQuality() - items[i].getQuality());
42
+            }
43
+            if (items[i].getQuality() < 50) {
44
+                items[i].setQuality(items[i].getQuality() + 1);
63 45
             }
64 46
         }
65 47
     }

+ 2
- 2
src/test/java/com/zipcodewilmington/gildedrose/InventoryTest.java View File

@@ -117,7 +117,7 @@ public class InventoryTest {
117 117
     @Test
118 118
     public void notNames(){
119 119
         int before = item1.getQuality();
120
-        int expected = 0;
120
+        int expected = 3;
121 121
         inventory.updateQuality();
122 122
         int actual = item1.getQuality();
123 123
 
@@ -126,7 +126,7 @@ public class InventoryTest {
126 126
 
127 127
     @Test
128 128
     public void lastTest(){
129
-        int actual = 6;
129
+        int actual = 1;
130 130
         inventory.updateQuality();
131 131
         int expected = agedBrie.getQuality();
132 132