From 1aae554b54d7d684536620e4d1d3fa7fd1872506 Mon Sep 17 00:00:00 2001 From: brianblessou Date: Sun, 12 May 2019 15:16:17 +0200 Subject: [PATCH] make the first if condition positive --- .../main/java/com/gildedrose/GildedRose.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Java/src/main/java/com/gildedrose/GildedRose.java b/Java/src/main/java/com/gildedrose/GildedRose.java index e6a13476..baec07d1 100644 --- a/Java/src/main/java/com/gildedrose/GildedRose.java +++ b/Java/src/main/java/com/gildedrose/GildedRose.java @@ -20,41 +20,37 @@ class GildedRose { } public void updateQuality() { + String SULFURA = "Sulfuras, Hand of Ragnaros"; + String AGED_BRIE = "Aged Brie"; + String BACKSTAGE = "Backstage passes to a TAFKAL80ETC concert"; + + for (Item item : items) { - if (item.name.equals("Sulfuras, Hand of Ragnaros")) { + if (item.name.equals(SULFURA)) { continue; } - /* if (!item.name.equals("Aged Brie")) { - if (!item.name.equals("Backstage passes to a TAFKAL80ETC concert")) { - decreaseQuality(item); - } - }*/ - - if (!item.name.equals("Aged Brie") - && !item.name.equals("Backstage passes to a TAFKAL80ETC concert")) { - decreaseQuality(item); - } else { + if (item.name.equals(AGED_BRIE) || item.name.equals(BACKSTAGE)) { increaseQuality(item); - if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) { + if (item.name.equals(BACKSTAGE)) { if (item.sellIn < 11) { increaseQuality(item); } - if (item.sellIn < 6) { increaseQuality(item); } } - + } else { + decreaseQuality(item); } item.sellIn = item.sellIn - 1; if (item.sellIn < 0) { - if (item.name.equals("Aged Brie")) { + if (item.name.equals(AGED_BRIE)) { increaseQuality(item); - } else if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) { + } else if (item.name.equals(BACKSTAGE)) { item.quality -= item.quality; } else { decreaseQuality(item);