mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-19 08:21:37 +00:00
🔨 convert LegendaryItem from anemic to rich
This commit is contained in:
parent
9ec9e54cb1
commit
4ccea7cf66
@ -1,6 +1,5 @@
|
|||||||
package com.gildedrose.items;
|
package com.gildedrose.items;
|
||||||
|
|
||||||
import com.gildedrose.item_helpers.ItemHandler;
|
|
||||||
import com.gildedrose.item_helpers.ItemType;
|
import com.gildedrose.item_helpers.ItemType;
|
||||||
import com.gildedrose.main.Item;
|
import com.gildedrose.main.Item;
|
||||||
|
|
||||||
@ -9,15 +8,15 @@ public class LegendaryItem implements ItemType {
|
|||||||
public static final int LEGENDARY_ITEM_QUALITY = 80;
|
public static final int LEGENDARY_ITEM_QUALITY = 80;
|
||||||
public static final String LEGENDARY = "Sulfuras, Hand of Ragnaros";
|
public static final String LEGENDARY = "Sulfuras, Hand of Ragnaros";
|
||||||
|
|
||||||
private final ItemHandler item;
|
private final Item item;
|
||||||
|
|
||||||
public LegendaryItem(Item item) {
|
public LegendaryItem(Item item) {
|
||||||
this.item = new ItemHandler(item);
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateQuality() {
|
public void updateQuality() {
|
||||||
item.decrementSellInDate();
|
decrementSellInDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -25,6 +24,10 @@ public class LegendaryItem implements ItemType {
|
|||||||
return LEGENDARY;
|
return LEGENDARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void decrementSellInDate() {
|
||||||
|
item.sellIn--;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isLegendary(Item item) {
|
public static boolean isLegendary(Item item) {
|
||||||
return item.name.equals(LEGENDARY);
|
return item.name.equals(LEGENDARY);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user