Seth 6 anni fa
parent
commit
e8f5b846e4

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

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

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

160
         Item[] items = {item};
160
         Item[] items = {item};
161
         Inventory inv = new Inventory(items);
161
         Inventory inv = new Inventory(items);
162
 
162
 
163
-        int expected = 19;
163
+        int expected = 20;
164
         inv.updateQuality();
164
         inv.updateQuality();
165
         int actual = item.getQuality();
165
         int actual = item.getQuality();
166
 
166
 
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