Sfoglia il codice sorgente

added conjured item to inventory

mpierse 6 anni fa
parent
commit
b3456dd5a9

+ 4
- 0
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java Vedi File

@@ -12,6 +12,10 @@ public class Inventory {
12 12
 
13 13
     public void updateQuality() {
14 14
         for (int i = 0; i < items.length; i++) {
15
+            if(items[i].getName().equals("Conjored") && items[i].getQuality()>0){
16
+                items[i].setQuality(items[i].getQuality()-1);
17
+            }
18
+
15 19
             if (!items[i].getName().equals("Aged Brie")
16 20
                     && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")
17 21
                     && !items[i].getName().equals("Sulfuras, Hand of Ragnaros")

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

@@ -15,6 +15,7 @@ public class InventoryTest {
15 15
     private Item ticket;
16 16
     private Item legend;
17 17
     private Item other;
18
+    private Item conjured;
18 19
 
19 20
     @Before
20 21
     public void setUp(){
@@ -22,9 +23,11 @@ public class InventoryTest {
22 23
         brie = new Item ("Aged Brie", 0,50);
23 24
         legend = new Item("Sulfuras, Hand of Ragnaros",0,50);
24 25
         other = new Item("other", 5,5);
25
-        items =new Item[]{ brie, ticket, legend, other};
26
+        conjured = new Item("Conjored", 5,5);
27
+        items =new Item[]{ brie, ticket, legend, other, conjured};
26 28
         store = new Inventory(items);
27 29
 
30
+
28 31
     }
29 32
 
30 33
     @Test
@@ -217,6 +220,14 @@ public class InventoryTest {
217 220
         Assert.assertEquals(expected,actual);
218 221
     }
219 222
 
223
+    @Test
224
+    public void conjuredCheckQuality() {
225
+        store.updateQuality();
226
+        int expected = 3;
227
+        int actual = conjured.getQuality();
228
+        Assert.assertEquals(expected, actual);
229
+    }
230
+
220 231
 
221 232
 }
222 233