mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-10 04:01:19 +00:00
lift-up conditional - isAgedBrie
This commit is contained in:
parent
519eb43d5f
commit
8f75b49648
@ -19,8 +19,49 @@ class GildedRose {
|
|||||||
|
|
||||||
public void updateQuality() {
|
public void updateQuality() {
|
||||||
for (Item item : items) {
|
for (Item item : items) {
|
||||||
|
doUpdateQuality(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void doUpdateQuality(Item item) {
|
||||||
|
// processing quality
|
||||||
|
boolean isAgedBrie = item.name.equals(AGED_BRIE);
|
||||||
|
|
||||||
|
if (isAgedBrie) {
|
||||||
// processing quality
|
// processing quality
|
||||||
if (!item.name.equals(AGED_BRIE) && !item.name.equals(BACKSTAGE_PASSES)) {
|
if (item.quality < QUALITY_LEVEL_50) {
|
||||||
|
item.quality = item.quality + 1;
|
||||||
|
|
||||||
|
// processing sell date
|
||||||
|
if (item.name.equals(BACKSTAGE_PASSES)) {
|
||||||
|
|
||||||
|
if (item.sellIn < SELL_IN_DAY11) {
|
||||||
|
if (item.quality < QUALITY_LEVEL_50) {
|
||||||
|
item.quality = item.quality + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.sellIn < SELL_IN_DAY6) {
|
||||||
|
if (item.quality < QUALITY_LEVEL_50) {
|
||||||
|
item.quality = item.quality + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// processing sell date
|
||||||
|
if (!item.name.equals(SULFURAS)) {
|
||||||
|
item.sellIn = item.sellIn - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// processing sell date
|
||||||
|
if (item.sellIn < SELL_IN_DAY0) {
|
||||||
|
if (item.quality < QUALITY_LEVEL_50) {
|
||||||
|
item.quality = item.quality + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!item.name.equals(BACKSTAGE_PASSES)) {
|
||||||
if (item.quality > QUALITY_LEVEL_0) {
|
if (item.quality > QUALITY_LEVEL_0) {
|
||||||
if (!item.name.equals(SULFURAS)) {
|
if (!item.name.equals(SULFURAS)) {
|
||||||
item.quality = item.quality - 1;
|
item.quality = item.quality - 1;
|
||||||
@ -56,23 +97,18 @@ class GildedRose {
|
|||||||
|
|
||||||
// processing sell date
|
// processing sell date
|
||||||
if (item.sellIn < SELL_IN_DAY0) {
|
if (item.sellIn < SELL_IN_DAY0) {
|
||||||
if (!item.name.equals(AGED_BRIE)) {
|
if (!item.name.equals(BACKSTAGE_PASSES)) {
|
||||||
if (!item.name.equals(BACKSTAGE_PASSES)) {
|
// processing quality
|
||||||
// processing quality
|
if (item.quality > QUALITY_LEVEL_0) {
|
||||||
if (item.quality > QUALITY_LEVEL_0) {
|
if (!item.name.equals(SULFURAS)) {
|
||||||
if (!item.name.equals(SULFURAS)) {
|
item.quality = item.quality - 1;
|
||||||
item.quality = item.quality - 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
item.quality = QUALITY_LEVEL_0;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (item.quality < QUALITY_LEVEL_50) {
|
item.quality = QUALITY_LEVEL_0;
|
||||||
item.quality = item.quality + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user