invert if condition

invert if condition to simplify the code
This commit is contained in:
Trobax 2022-11-23 16:54:56 +01:00
parent 7422960de8
commit bdcd441019

View File

@ -22,31 +22,31 @@ class GildedRose {
}
private static void updateQuality(Item item) {
if (!item.name.equals("Aged Brie")
&& !item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
if (item.name.equals("Aged Brie")
|| item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
if (item.quality < 50) {
item.quality++;
if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
if (item.sellIn < 11) {
if (item.quality < 50) {
item.quality++;
}
}
if (item.sellIn < 6) {
if (item.quality < 50) {
item.quality++;
}
}
}
}
} else {
if (item.quality > 0) {
if (!item.name.equals("Sulfuras, Hand of Ragnaros")) {
item.quality--;
}
}
} else {
if (item.quality < 50) {
item.quality++;
if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
if (item.sellIn < 11) {
if (item.quality < 50) {
item.quality++;
}
}
if (item.sellIn < 6) {
if (item.quality < 50) {
item.quality++;
}
}
}
}
}
}