mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-04 09:11:39 +00:00
em, merge if else
This commit is contained in:
parent
7ae1a6a238
commit
f2cd52d932
@ -16,46 +16,52 @@ class GildedRose {
|
|||||||
if (items[i].name.equals(AGED_BRIE)) {
|
if (items[i].name.equals(AGED_BRIE)) {
|
||||||
increaseQualityByOne(i);
|
increaseQualityByOne(i);
|
||||||
} else if (items[i].name.equals(BACKSTAGE_PASSES)) {
|
} else if (items[i].name.equals(BACKSTAGE_PASSES)) {
|
||||||
if (items[i].sellIn < 6) {
|
increaseQualityBackstage(i);
|
||||||
increaseQualityByThree(i);
|
|
||||||
} else if (items[i].sellIn < 11) {
|
|
||||||
increaseQualityByTwo(i);
|
|
||||||
} else {
|
|
||||||
increaseQualityByOne(i);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
decreaseQualityByOne(i);
|
decreaseQualityByOne(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!items[i].name.equals(SULFURAS)) {
|
decreaseSellInEachDay(i);
|
||||||
items[i].sellIn = items[i].sellIn - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (items[i].sellIn < 0) {
|
if (items[i].sellIn < 0) {
|
||||||
if (items[i].name.equals(AGED_BRIE)) {
|
if (items[i].name.equals(AGED_BRIE)) {
|
||||||
increaseQualityByOne(i);
|
increaseQualityByOne(i);
|
||||||
|
} else if (items[i].name.equals(BACKSTAGE_PASSES)) {
|
||||||
|
items[i].quality = 0;
|
||||||
} else {
|
} else {
|
||||||
if (items[i].name.equals(BACKSTAGE_PASSES)) {
|
decreaseQualityByOne(i);
|
||||||
items[i].quality = 0;
|
|
||||||
} else {
|
|
||||||
decreaseQualityByOne(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void decreaseSellInEachDay(int i) {
|
||||||
|
if (!items[i].name.equals(SULFURAS)) {
|
||||||
|
items[i].sellIn--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void increaseQualityBackstage(int i) {
|
||||||
|
if (items[i].sellIn < 6) {
|
||||||
|
increaseQualityByThree(i);
|
||||||
|
} else if (items[i].sellIn < 11) {
|
||||||
|
increaseQualityByTwo(i);
|
||||||
|
} else {
|
||||||
|
increaseQualityByOne(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void decreaseQualityByOne(int i) {
|
private void decreaseQualityByOne(int i) {
|
||||||
if (items[i].quality > 0) {
|
if (items[i].quality > 0) {
|
||||||
if (!items[i].name.equals(SULFURAS)) {
|
if (!items[i].name.equals(SULFURAS)) {
|
||||||
items[i].quality = items[i].quality - 1;
|
items[i].quality--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void increaseQualityByOne(int i) {
|
private void increaseQualityByOne(int i) {
|
||||||
if (items[i].quality < 50) {
|
if (items[i].quality < 50) {
|
||||||
items[i].quality = items[i].quality + 1;
|
items[i].quality++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user