mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Introduced new item "Conjured"
This commit is contained in:
parent
45c0a3a53b
commit
740c58ef2d
@ -8,6 +8,7 @@ import com.gildedrose.enums.ProductType;
|
|||||||
import com.gildedrose.generic.ItemType;
|
import com.gildedrose.generic.ItemType;
|
||||||
import com.gildedrose.types.AgedBrie;
|
import com.gildedrose.types.AgedBrie;
|
||||||
import com.gildedrose.types.Backstage;
|
import com.gildedrose.types.Backstage;
|
||||||
|
import com.gildedrose.types.Conjured;
|
||||||
import com.gildedrose.types.Others;
|
import com.gildedrose.types.Others;
|
||||||
import com.gildedrose.types.Sulfuras;
|
import com.gildedrose.types.Sulfuras;
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ public class ProductFactory {
|
|||||||
productMap.put(ProductType.AGED_BRIE, new AgedBrie());
|
productMap.put(ProductType.AGED_BRIE, new AgedBrie());
|
||||||
productMap.put(ProductType.SULFURAS, new Sulfuras());
|
productMap.put(ProductType.SULFURAS, new Sulfuras());
|
||||||
productMap.put(ProductType.BACKSTAGE_PASSES, new Backstage());
|
productMap.put(ProductType.BACKSTAGE_PASSES, new Backstage());
|
||||||
|
productMap.put(ProductType.CONJURED, new Conjured());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
|||||||
@ -9,7 +9,8 @@ public enum ProductType {
|
|||||||
|
|
||||||
AGED_BRIE("Aged Brie"),
|
AGED_BRIE("Aged Brie"),
|
||||||
BACKSTAGE_PASSES("Backstage passes to a TAFKAL80ETC concert"),
|
BACKSTAGE_PASSES("Backstage passes to a TAFKAL80ETC concert"),
|
||||||
SULFURAS("Sulfuras, Hand of Ragnaros");
|
SULFURAS("Sulfuras, Hand of Ragnaros"),
|
||||||
|
CONJURED("Conjured Mana Cake");
|
||||||
|
|
||||||
private final String productName;
|
private final String productName;
|
||||||
|
|
||||||
|
|||||||
16
Java/src/main/java/com/gildedrose/types/Conjured.java
Normal file
16
Java/src/main/java/com/gildedrose/types/Conjured.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package com.gildedrose.types;
|
||||||
|
|
||||||
|
import com.gildedrose.Item;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* "Conjured" items degrade in Quality twice as fast as normal items
|
||||||
|
* @author VIJAY G
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Conjured extends Others {
|
||||||
|
|
||||||
|
public void decreaseQualityByValue(Item item, Integer value) {
|
||||||
|
item.quality -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
21
Java/src/test/java/com/gildedrose/types/ConjuredTest.java
Normal file
21
Java/src/test/java/com/gildedrose/types/ConjuredTest.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package com.gildedrose.types;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import com.gildedrose.Item;
|
||||||
|
import com.gildedrose.enums.ProductType;
|
||||||
|
|
||||||
|
public class ConjuredTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConjuredUpdateQuality() {
|
||||||
|
Item item = new Item(ProductType.CONJURED.name(), 2, 3);
|
||||||
|
Conjured conjured = new Conjured();
|
||||||
|
conjured.updateQuality(item);
|
||||||
|
assertEquals(item.quality, 1);
|
||||||
|
assertEquals(item.sellIn, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user