Seth 6 years ago
parent
commit
e8f5b846e4

+ 17
- 1
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java View File

@@ -6,6 +6,7 @@ public class Inventory {
6 6
     private final String brie = "Aged Brie";
7 7
     private final String pass = "Backstage passes to a TAFKAL80ETC concert";
8 8
     private final String hand = "Sulfuras, Hand of Ragnaros";
9
+    private final String conj = "conjured";
9 10
 
10 11
     public Inventory(Item[] items) {
11 12
         super();
@@ -40,10 +41,20 @@ public class Inventory {
40 41
                     soldOut(items[i]);
41 42
                     break;
42 43
 
44
+                case conj :
45
+
46
+                    doubleExp(items[i]);
47
+                    sellOne(items[i]);
48
+                    betterWithAge(items[i]);
49
+                    break;
50
+
51
+
43 52
                 default :
44 53
 
45
-                    //soldOut(items[i]);
54
+
55
+                    sellOne(items[i]);
46 56
                     expiring(items[i]);
57
+                    betterWithAge(items[i]);
47 58
 
48 59
             }
49 60
 
@@ -99,6 +110,11 @@ public class Inventory {
99 110
 
100 111
     }
101 112
 
113
+    public void doubleExp(Item item) {
114
+        item.setQuality(item.getQuality() - 2);
115
+
116
+    }
117
+
102 118
 }
103 119
         /*for (int i = 0; i < items.length; i++) {
104 120
             if (!items[i].getName().equals("Aged Brie")

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

@@ -160,7 +160,7 @@ public class InventoryTest {
160 160
         Item[] items = {item};
161 161
         Inventory inv = new Inventory(items);
162 162
 
163
-        int expected = 19;
163
+        int expected = 20;
164 164
         inv.updateQuality();
165 165
         int actual = item.getQuality();
166 166
 
@@ -241,6 +241,31 @@ public class InventoryTest {
241 241
 
242 242
     }
243 243
 
244
+    @Test
245
+    public void conjuredTest01() {
246
+        Item item = new Item("conjured", 5, 10);
247
+        Item[] items = {item};
248
+        Inventory inv = new Inventory(items);
249
+
250
+        int expected = 8;
251
+        inv.updateQuality();
252
+        int actual = item.getQuality();
253
+
254
+        Assert.assertEquals(expected, actual);
255
+
256
+    }
257
+/*
258
+
259
+    @Test
260
+    public void conjuredTest02() {
261
+        Item item = new Item("conjure", -1, 10);
262
+        Item[] items = {item};
263
+        Inventory inv = new Inventory(items);
264
+
265
+        int expected =
266
+    }
267
+
268
+*/
244 269
 
245 270
 }
246 271