Browse Source

Updated backstage passes to default to 0 quality when sellin is 0

Lauren Green 6 years ago
parent
commit
983bbc4049

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

56
                 increaseQualityByTwo(i);
56
                 increaseQualityByTwo(i);
57
                 if ((items[i].getSellIn() <= 5)) {
57
                 if ((items[i].getSellIn() <= 5)) {
58
                 increaseQualityByOne(i);
58
                 increaseQualityByOne(i);
59
-            } } else if ((items[i].getName().equals("Conjured")) || (items[i].getSellIn() == 0)) {
59
+                }
60
+                if (items[i].getSellIn() == 0) {
61
+                    items[i].setQuality(0);
62
+                }
63
+            } else if ((items[i].getName().equals("Conjured")) || (items[i].getSellIn() == 0)) {
60
                 decreaseQualityByTwo(i);
64
                 decreaseQualityByTwo(i);
61
             } else {
65
             } else {
62
                 decreaseQualityByOne(i);
66
                 decreaseQualityByOne(i);

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

188
     }
188
     }
189
 
189
 
190
     @Test
190
     @Test
191
+    public void backstagePasses0DaysUpdateQualityTest(){
192
+        //Given
193
+        Item backstagePass = new Item("Backstage Passes", 1, 10);
194
+        Item[] itemArr = new Item[1];
195
+        itemArr[0] = backstagePass;
196
+        Inventory newInv = new Inventory(itemArr);
197
+        int expected = 0;
198
+
199
+        //When
200
+        newInv.updateSellIn();
201
+        newInv.updateQuality();
202
+        newInv.updateSellIn();
203
+        newInv.updateQuality();
204
+
205
+        //Then
206
+        int actual = backstagePass.getQuality();
207
+
208
+        Assert.assertEquals(expected, actual);
209
+    }
210
+
211
+    @Test
191
     public void agedBrieUpdateQualityTest(){
212
     public void agedBrieUpdateQualityTest(){
192
         //Given
213
         //Given
193
         Item agedBrie = new Item("Aged Brie", 20, 5);
214
         Item agedBrie = new Item("Aged Brie", 20, 5);