Merge pull request #7 from Decker-Matthew-R/Decker-Refactor-Branch3

Added Conjure Item
This commit is contained in:
Matt Decker 2022-07-02 12:20:14 -05:00 committed by GitHub
commit 06bfb84143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ class GildedRose {
public static final String AGED_BRIE = "Aged Brie"; public static final String AGED_BRIE = "Aged Brie";
public static final String SULFURAS = "Sulfuras, Hand of Ragnaros"; public static final String SULFURAS = "Sulfuras, Hand of Ragnaros";
public static final String BACKSTAGE = "Backstage passes to a TAFKAL80ETC concert"; public static final String BACKSTAGE = "Backstage passes to a TAFKAL80ETC concert";
public static final String CONJURED = "Conjured Mana Cake";
private Item[] items; private Item[] items;
@ -19,11 +20,12 @@ class GildedRose {
} }
private void updateItemQuality(Item item) { private void updateItemQuality(Item item) {
int degradeRate = item.name.equals(CONJURED) ? -2 : -1;
if (!item.name.equals(AGED_BRIE) if (!item.name.equals(AGED_BRIE)
&& !item.name.equals(BACKSTAGE)) { && !item.name.equals(BACKSTAGE)) {
if (item.quality > 0) { if (item.quality > 0) {
if (!item.name.equals(SULFURAS)) { if (!item.name.equals(SULFURAS)) {
adjustQuality(item, -1); adjustQuality(item, degradeRate);
} }
} }
} else { } else {
@ -48,7 +50,7 @@ class GildedRose {
if (!item.name.equals(AGED_BRIE)) { if (!item.name.equals(AGED_BRIE)) {
if (!item.name.equals(BACKSTAGE)) { if (!item.name.equals(BACKSTAGE)) {
if (!item.name.equals(SULFURAS)) { if (!item.name.equals(SULFURAS)) {
adjustQuality(item, -1); adjustQuality(item, degradeRate);
} }
} else { } else {
item.quality = item.quality - item.quality; item.quality = item.quality - item.quality;