Jared Norris преди 8 години
родител
ревизия
214cb57500
променени са 3 файла, в които са добавени 43 реда и са изтрити 1 реда
  1. 17
    0
      Inventory.java
  2. 25
    0
      InventoryTest.java
  3. 1
    1
      README.MD

+ 17
- 0
Inventory.java Целия файл

@@ -19,6 +19,23 @@ public class Inventory
19 19
     }
20 20
 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvBIG OL ENUMvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
21 21
     public enum BigSellers {
22
+//-------------------------CONJURED MANA BISCUIT------------------------------
23
+        CONJURED() {
24
+            @Override public void quality(Item x) {
25
+              int currentQuality = x.getQuality();
26
+              int sellIn = x.getSellIn();
27
+              //------------------------------------------
28
+              if (currentQuality > 0) {
29
+                  if(sellIn >= 0) {
30
+                    x.setQuality(currentQuality - 2);
31
+                  }
32
+                  else x.setQuality(currentQuality - 4);
33
+              }
34
+              //------------------------------------------
35
+              x.setSellIn(sellIn - 1);
36
+           }
37
+        },
38
+//-----------------------------------------------------------------------------
22 39
 //------------------------------SULFURAS---------------------------------------
23 40
         SULFURAS() {
24 41
             @Override public void quality(Item x) {

+ 25
- 0
InventoryTest.java Целия файл

@@ -11,11 +11,13 @@ public class InventoryTest {
11 11
 
12 12
     private Item sulfuras;
13 13
     private Item normalItem;
14
+    private Item conjuredItem;
14 15
 
15 16
     @Before
16 17
     public void setup(){
17 18
         sulfuras = new Item("Sulfuras, Hand of Ragnaros", 0, 80);
18 19
         normalItem = new Item(NORMAL_ITEM_NAME, 10, 20);
20
+        conjuredItem = new Item("Conjured Mana Biscuit", 10, 30);
19 21
     }
20 22
 
21 23
     @Test
@@ -182,4 +184,27 @@ public class InventoryTest {
182 184
         assertEquals(MAX_QUALITY, backStagePass10DaysAway.getQuality());
183 185
         assertEquals(MAX_QUALITY, backStagePass5DaysAway.getQuality());
184 186
     }
187
+    //-------------------------Conjured Item-----------------------------
188
+    @Test
189
+    public void testUpdate_for_ConjuredItem() throws Exception {
190
+        int expectedQuality = conjuredItem.getQuality() - 2;
191
+        Item[] items = {conjuredItem};
192
+        Inventory sut = new Inventory(items);
193
+
194
+        sut.updateQuality();
195
+
196
+        assertEquals(expectedQuality, conjuredItem.getQuality());
197
+    }
198
+    
199
+    @Test
200
+    public void testUpdate_for_ConjuredItem_PastSellBy() throws Exception {
201
+        Item conjuredItemPastSellBy = new Item("Conjured Mana Biscuit", -1, 30);
202
+        int expectedQuality = conjuredItemPastSellBy.getQuality() - 4;
203
+        Item[] items = {conjuredItemPastSellBy};
204
+        Inventory sut = new Inventory(items);
205
+
206
+        sut.updateQuality();
207
+
208
+        assertEquals(expectedQuality, conjuredItemPastSellBy.getQuality());
209
+    }
185 210
 }

+ 1
- 1
README.MD Целия файл

@@ -18,7 +18,7 @@
18 18
 3. DO NOT CHANGE THE TEST
19 19
 
20 20
 # Levels
21
-This lab is divided into two levels. If you are 90% done with your labs or if you want to challenge yourself, get level2 with `git checkout level2` after you clone the repository. Otherwise, work on the master branch. 
21
+This lab is divided into two levels. If you are 90% done with your labs or if you want to challenge yourself, get level2 with `git checkout level2` after you clone the repository. Otherwise, work on the master branch.
22 22
 
23 23
 # Part 1 - Original Description of the Gilded Rose
24 24