mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
Extract the legendary (Sulfuras) Gilded Rose item behaviour
This commit is contained in:
parent
ce308107f2
commit
fdd930f5cd
@ -13,10 +13,11 @@ public class GildedRoseItemFactory {
|
|||||||
static final Pattern CONJURED_ITEM = Pattern.compile("Conjured.*", CASE_INSENSITIVE);
|
static final Pattern CONJURED_ITEM = Pattern.compile("Conjured.*", CASE_INSENSITIVE);
|
||||||
|
|
||||||
public static GildedRoseItem create(Item item) {
|
public static GildedRoseItem create(Item item) {
|
||||||
if (LEGENDARY_NAME_PATTERN.matcher(item.name).matches()
|
if (AGING_ITEM.matcher(item.name).matches()
|
||||||
|| AGING_ITEM.matcher(item.name).matches()
|
|
||||||
|| CONJURED_ITEM.matcher(item.name).matches()) {
|
|| CONJURED_ITEM.matcher(item.name).matches()) {
|
||||||
return new NonStandardGildedRoseItem(item);
|
return new NonStandardGildedRoseItem(item);
|
||||||
|
} else if (LEGENDARY_NAME_PATTERN.matcher(item.name).matches()) {
|
||||||
|
return new LegendaryGildedRoseItem(item);
|
||||||
} else {
|
} else {
|
||||||
return new StandardGildedRoseItem(item);
|
return new StandardGildedRoseItem(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.gildedrose.items;
|
||||||
|
|
||||||
|
import com.gildedrose.Item;
|
||||||
|
|
||||||
|
public class LegendaryGildedRoseItem extends AbstractGildedRoseItem {
|
||||||
|
|
||||||
|
public LegendaryGildedRoseItem(Item item) {
|
||||||
|
super(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GildedRoseItem updateQuality() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -42,14 +42,18 @@ class GildedRoseTest {
|
|||||||
@Test
|
@Test
|
||||||
void updateQuality_standardItem_maxQuality50() {
|
void updateQuality_standardItem_maxQuality50() {
|
||||||
GildedRose app = createApp(createItem("standard", 10, 60));
|
GildedRose app = createApp(createItem("standard", 10, 60));
|
||||||
|
|
||||||
app.updateQuality();
|
app.updateQuality();
|
||||||
|
|
||||||
assertEquals(49, app.items[0].quality);
|
assertEquals(49, app.items[0].quality);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void updateQuality_legendaryItem() {
|
void updateQuality_legendaryItem() {
|
||||||
fail("NYI");
|
GildedRose app = createApp(createItem("Sulfuras, Hand of Ragnaros ", 10, 80));
|
||||||
|
app.updateQuality();
|
||||||
|
|
||||||
|
assertEquals(10, app.items[0].sellIn);
|
||||||
|
assertEquals(80, app.items[0].quality);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user