mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 06:21:29 +00:00
moves lowest quality value
This commit is contained in:
parent
bdb783786c
commit
7b0e2daa3d
@ -7,7 +7,6 @@ import com.gildedrose.item.QualityValues;
|
|||||||
|
|
||||||
class GildedRose {
|
class GildedRose {
|
||||||
|
|
||||||
private static final int LOWEST_QUALITY_VALUE_POSSIBLE = 0;
|
|
||||||
Item[] items;
|
Item[] items;
|
||||||
|
|
||||||
public GildedRose(Item[] items) {
|
public GildedRose(Item[] items) {
|
||||||
@ -18,7 +17,7 @@ class GildedRose {
|
|||||||
for (Item item : items) {
|
for (Item item : items) {
|
||||||
customisedItem(item).updateState();
|
customisedItem(item).updateState();
|
||||||
if (hasReachedLowestQualityValue(item)) {
|
if (hasReachedLowestQualityValue(item)) {
|
||||||
item.quality = LOWEST_QUALITY_VALUE_POSSIBLE;
|
item.quality = QualityValues.lowestValuePossible();
|
||||||
} else if (hasReachedHighestQualityValue(item)) {
|
} else if (hasReachedHighestQualityValue(item)) {
|
||||||
item.quality = QualityValues.highestValuePossible(item);
|
item.quality = QualityValues.highestValuePossible(item);
|
||||||
}
|
}
|
||||||
@ -30,7 +29,7 @@ class GildedRose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasReachedLowestQualityValue(Item item) {
|
private boolean hasReachedLowestQualityValue(Item item) {
|
||||||
return item.quality < LOWEST_QUALITY_VALUE_POSSIBLE;
|
return item.quality < QualityValues.lowestValuePossible();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasReachedHighestQualityValue(Item item) {
|
private boolean hasReachedHighestQualityValue(Item item) {
|
||||||
|
|||||||
@ -2,6 +2,10 @@ package com.gildedrose.item;
|
|||||||
|
|
||||||
public final class QualityValues {
|
public final class QualityValues {
|
||||||
|
|
||||||
|
public static int lowestValuePossible() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static int highestValuePossible(Item item) {
|
public static int highestValuePossible(Item item) {
|
||||||
if (item.name.equals(CustomisedItemFactory.SULFURAS)) {
|
if (item.name.equals(CustomisedItemFactory.SULFURAS)) {
|
||||||
return 80;
|
return 80;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user