diff --git a/Java/src/main/java/com/gildedrose/GildedRose.java b/Java/src/main/java/com/gildedrose/GildedRose.java index cce951e6..1d113c5a 100644 --- a/Java/src/main/java/com/gildedrose/GildedRose.java +++ b/Java/src/main/java/com/gildedrose/GildedRose.java @@ -17,47 +17,47 @@ class GildedRose { if (item.name.equals("Sulfuras, Hand of Ragnaros")) { return; } - if (item.name.equals("Aged Brie")) { - if (item.quality < 50) { - item.quality = item.quality + 1; - } + increaseQuality(item); } else if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) { - if (item.quality < 50) { - item.quality = item.quality + 1; - + increaseQuality(item); + if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) { if (item.sellIn < 11) { - if (item.quality < 50) { - item.quality = item.quality + 1; - } + increaseQuality(item); } if (item.sellIn < 6) { - if (item.quality < 50) { - item.quality = item.quality + 1; - } + increaseQuality(item); } } - } else if (item.quality > 0) { - item.quality = item.quality - 1; + } else { + decreaseQuality(item); } item.sellIn = item.sellIn - 1; if (item.sellIn < 0) { if (item.name.equals("Aged Brie")) { - if (item.quality < 50) { - item.quality = item.quality + 1; - } + increaseQuality(item); } else { if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) { item.quality = item.quality - item.quality; } else { - if (item.quality > 0) { - item.quality = item.quality - 1; - } + decreaseQuality(item); } } } } + + public void decreaseQuality(Item item) { + if (item.quality > 0) { + item.quality = item.quality - 1; + } + } + + public void increaseQuality(Item item) { + if (item.quality < 50) { + item.quality = item.quality + 1; + } + } }