Przeglądaj źródła

added conjured item

Jared Norris 8 lat temu
rodzic
commit
214cb57500
3 zmienionych plików z 43 dodań i 1 usunięć
  1. 17
    0
      Inventory.java
  2. 25
    0
      InventoryTest.java
  3. 1
    1
      README.MD

+ 17
- 0
Inventory.java Wyświetl plik

19
     }
19
     }
20
 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvBIG OL ENUMvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
20
 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvBIG OL ENUMvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
21
     public enum BigSellers {
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
 //------------------------------SULFURAS---------------------------------------
39
 //------------------------------SULFURAS---------------------------------------
23
         SULFURAS() {
40
         SULFURAS() {
24
             @Override public void quality(Item x) {
41
             @Override public void quality(Item x) {

+ 25
- 0
InventoryTest.java Wyświetl plik

11
 
11
 
12
     private Item sulfuras;
12
     private Item sulfuras;
13
     private Item normalItem;
13
     private Item normalItem;
14
+    private Item conjuredItem;
14
 
15
 
15
     @Before
16
     @Before
16
     public void setup(){
17
     public void setup(){
17
         sulfuras = new Item("Sulfuras, Hand of Ragnaros", 0, 80);
18
         sulfuras = new Item("Sulfuras, Hand of Ragnaros", 0, 80);
18
         normalItem = new Item(NORMAL_ITEM_NAME, 10, 20);
19
         normalItem = new Item(NORMAL_ITEM_NAME, 10, 20);
20
+        conjuredItem = new Item("Conjured Mana Biscuit", 10, 30);
19
     }
21
     }
20
 
22
 
21
     @Test
23
     @Test
182
         assertEquals(MAX_QUALITY, backStagePass10DaysAway.getQuality());
184
         assertEquals(MAX_QUALITY, backStagePass10DaysAway.getQuality());
183
         assertEquals(MAX_QUALITY, backStagePass5DaysAway.getQuality());
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 Wyświetl plik

18
 3. DO NOT CHANGE THE TEST
18
 3. DO NOT CHANGE THE TEST
19
 
19
 
20
 # Levels
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
 # Part 1 - Original Description of the Gilded Rose
23
 # Part 1 - Original Description of the Gilded Rose
24
 
24