correct bug: condition on sellIn for Backstage should be lower than 10 and 05 instead of 11 or 06

This commit is contained in:
brianblessou 2019-05-12 15:29:17 +02:00
parent 1aae554b54
commit a273600de7

View File

@ -19,6 +19,20 @@ class GildedRose {
} }
} }
private void updateNumberOfdayToSellRemaining(Item item) {
item.sellIn -= 1;
}
private boolean itemHasExpired(Item item) {
boolean condition;
if (item.sellIn < 0) {
condition=true;
} else {
condition=false;
}
return condition;
}
public void updateQuality() { public void updateQuality() {
String SULFURA = "Sulfuras, Hand of Ragnaros"; String SULFURA = "Sulfuras, Hand of Ragnaros";
String AGED_BRIE = "Aged Brie"; String AGED_BRIE = "Aged Brie";
@ -30,24 +44,26 @@ class GildedRose {
continue; continue;
} }
if (item.name.equals(AGED_BRIE) || item.name.equals(BACKSTAGE)) { updateNumberOfdayToSellRemaining(item);
if (item.name.equals(AGED_BRIE)) {
increaseQuality(item); increaseQuality(item);
if (item.name.equals(BACKSTAGE)) { } else if (item.name.equals(BACKSTAGE)) {
if (item.sellIn < 11) { increaseQuality(item);
increaseQuality(item);
} if (item.sellIn < 10) {
if (item.sellIn < 6) { increaseQuality(item);
increaseQuality(item);
}
} }
if (item.sellIn < 5) {
increaseQuality(item);
}
} else { } else {
decreaseQuality(item); decreaseQuality(item);
} }
item.sellIn = item.sellIn - 1;
if (itemHasExpired(item)) {
if (item.sellIn < 0) {
if (item.name.equals(AGED_BRIE)) { if (item.name.equals(AGED_BRIE)) {
increaseQuality(item); increaseQuality(item);
} else if (item.name.equals(BACKSTAGE)) { } else if (item.name.equals(BACKSTAGE)) {