mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 16:01:42 +00:00
Extract quality inc and decrease into private method
This commit is contained in:
parent
8b94d335e8
commit
2fb5d2bc77
@ -20,23 +20,23 @@ class GildedRose {
|
||||
&& !currentItem.name.equals(ITEM_BACKSTAGE_PASSES)) {
|
||||
if (currentItem.quality > MIN_QUALITY_LEVEL) {
|
||||
if (!currentItem.name.equals(ITEM_SULFURAS_HAND_OF_RAGNAROS)) {
|
||||
currentItem.quality = currentItem.quality - 1;
|
||||
decreaseQuality(currentItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentItem.quality < MAX_QUALITY_LEVEL) {
|
||||
currentItem.quality = currentItem.quality + 1;
|
||||
increaseQuality(currentItem);
|
||||
|
||||
if (currentItem.name.equals(ITEM_BACKSTAGE_PASSES)) {
|
||||
if (currentItem.sellIn < 11) {
|
||||
if (currentItem.quality < MAX_QUALITY_LEVEL) {
|
||||
currentItem.quality = currentItem.quality + 1;
|
||||
increaseQuality(currentItem);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentItem.sellIn < 6) {
|
||||
if (currentItem.quality < MAX_QUALITY_LEVEL) {
|
||||
currentItem.quality = currentItem.quality + 1;
|
||||
increaseQuality(currentItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -52,7 +52,7 @@ class GildedRose {
|
||||
if (!currentItem.name.equals(ITEM_BACKSTAGE_PASSES)) {
|
||||
if (currentItem.quality > MIN_QUALITY_LEVEL) {
|
||||
if (!currentItem.name.equals(ITEM_SULFURAS_HAND_OF_RAGNAROS)) {
|
||||
currentItem.quality = currentItem.quality - 1;
|
||||
decreaseQuality(currentItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -60,10 +60,18 @@ class GildedRose {
|
||||
}
|
||||
} else {
|
||||
if (currentItem.quality < MAX_QUALITY_LEVEL) {
|
||||
currentItem.quality = currentItem.quality + 1;
|
||||
increaseQuality(currentItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void decreaseQuality(Item item) {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
|
||||
private void increaseQuality(Item item) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user