mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
34 lines
882 B
Java
34 lines
882 B
Java
package com.gildedrose.item;
|
|
|
|
public abstract class CustomisedItem {
|
|
|
|
private final Item item;
|
|
|
|
CustomisedItem(Item item) {
|
|
this.item = item;
|
|
}
|
|
|
|
public final void updateState() {
|
|
item.sellIn = updatedItemSellIn();
|
|
item.quality = updatedItemQuality();
|
|
|
|
if (hasReachedLowestQualityValue()) {
|
|
item.quality = QualityValues.lowestValuePossible();
|
|
} else if (hasReachedHighestQualityValue()) {
|
|
item.quality = QualityValues.highestValuePossible(item);
|
|
}
|
|
}
|
|
|
|
abstract int updatedItemSellIn();
|
|
|
|
abstract int updatedItemQuality();
|
|
|
|
private boolean hasReachedHighestQualityValue() {
|
|
return item.quality > QualityValues.highestValuePossible(item);
|
|
}
|
|
|
|
private boolean hasReachedLowestQualityValue() {
|
|
return item.quality < QualityValues.lowestValuePossible();
|
|
}
|
|
}
|