lift-up conditional - isAgedBrie

This commit is contained in:
villanibe 2025-06-26 15:26:49 +02:00
parent 519eb43d5f
commit 8f75b49648

View File

@ -19,8 +19,49 @@ class GildedRose {
public void updateQuality() {
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
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.name.equals(SULFURAS)) {
item.quality = item.quality - 1;
@ -56,23 +97,18 @@ class GildedRose {
// processing sell date
if (item.sellIn < SELL_IN_DAY0) {
if (!item.name.equals(AGED_BRIE)) {
if (!item.name.equals(BACKSTAGE_PASSES)) {
// processing quality
if (item.quality > QUALITY_LEVEL_0) {
if (!item.name.equals(SULFURAS)) {
item.quality = item.quality - 1;
}
if (!item.name.equals(BACKSTAGE_PASSES)) {
// processing quality
if (item.quality > QUALITY_LEVEL_0) {
if (!item.name.equals(SULFURAS)) {
item.quality = item.quality - 1;
}
} else {
item.quality = QUALITY_LEVEL_0;
}
} else {
if (item.quality < QUALITY_LEVEL_50) {
item.quality = item.quality + 1;
}
item.quality = QUALITY_LEVEL_0;
}
}
}
}
}