Introduced new item "Conjured"

This commit is contained in:
Vijay G 2023-06-12 21:55:34 +05:30
parent 45c0a3a53b
commit 740c58ef2d
4 changed files with 41 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import com.gildedrose.enums.ProductType;
import com.gildedrose.generic.ItemType;
import com.gildedrose.types.AgedBrie;
import com.gildedrose.types.Backstage;
import com.gildedrose.types.Conjured;
import com.gildedrose.types.Others;
import com.gildedrose.types.Sulfuras;
@ -24,6 +25,7 @@ public class ProductFactory {
productMap.put(ProductType.AGED_BRIE, new AgedBrie());
productMap.put(ProductType.SULFURAS, new Sulfuras());
productMap.put(ProductType.BACKSTAGE_PASSES, new Backstage());
productMap.put(ProductType.CONJURED, new Conjured());
}
@SuppressWarnings("rawtypes")

View File

@ -9,7 +9,8 @@ public enum ProductType {
AGED_BRIE("Aged Brie"),
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;

View 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;
}
}

View 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);
}
}