Ver código fonte

added conjured item to inventory

mpierse 6 anos atrás
pai
commit
b3456dd5a9

+ 4
- 0
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java Ver arquivo

12
 
12
 
13
     public void updateQuality() {
13
     public void updateQuality() {
14
         for (int i = 0; i < items.length; i++) {
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
             if (!items[i].getName().equals("Aged Brie")
19
             if (!items[i].getName().equals("Aged Brie")
16
                     && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")
20
                     && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")
17
                     && !items[i].getName().equals("Sulfuras, Hand of Ragnaros")
21
                     && !items[i].getName().equals("Sulfuras, Hand of Ragnaros")

+ 12
- 1
src/test/java/com/zipcodewilmington/gildedrose/InventoryTest.java Ver arquivo

15
     private Item ticket;
15
     private Item ticket;
16
     private Item legend;
16
     private Item legend;
17
     private Item other;
17
     private Item other;
18
+    private Item conjured;
18
 
19
 
19
     @Before
20
     @Before
20
     public void setUp(){
21
     public void setUp(){
22
         brie = new Item ("Aged Brie", 0,50);
23
         brie = new Item ("Aged Brie", 0,50);
23
         legend = new Item("Sulfuras, Hand of Ragnaros",0,50);
24
         legend = new Item("Sulfuras, Hand of Ragnaros",0,50);
24
         other = new Item("other", 5,5);
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
         store = new Inventory(items);
28
         store = new Inventory(items);
27
 
29
 
30
+
28
     }
31
     }
29
 
32
 
30
     @Test
33
     @Test
217
         Assert.assertEquals(expected,actual);
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