mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
48 lines
1.0 KiB
Java
48 lines
1.0 KiB
Java
package com.gildedrose;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
class GildedRose {
|
|
public static final String AGED_BRIE = "Aged Brie";
|
|
public static final String SULFURAS = "Sulfuras, Hand of Ragnaros";
|
|
public static final String BACKSTAGE_PASSES = "Backstage passes to a TAFKAL80ETC concert";
|
|
|
|
final List<Item> items;
|
|
|
|
public GildedRose(Item[] items) {
|
|
this.items = Arrays.asList(items);
|
|
}
|
|
|
|
public void updateQuality() {
|
|
items.forEach(GildedRose::handleDay);
|
|
}
|
|
|
|
private static void handleDay(Item item) {
|
|
switch (item.name) {
|
|
case AGED_BRIE:
|
|
handleAgedBrie(item);
|
|
return;
|
|
case SULFURAS:
|
|
handleSulfuras(item);
|
|
return;
|
|
case BACKSTAGE_PASSES:
|
|
BackstagePassesItem.handleDay(item);
|
|
return;
|
|
default:
|
|
GenericItem.handleDay(item);
|
|
}
|
|
}
|
|
|
|
|
|
private static void handleSulfuras(Item item) {
|
|
}
|
|
|
|
private static void handleAgedBrie(Item item) {
|
|
if (item.quality != 50) {
|
|
item.quality += 1;
|
|
}
|
|
item.sellIn -= 1;
|
|
}
|
|
}
|