mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-11 04:31:21 +00:00
enhance for loop to be readable
This commit is contained in:
parent
1c56c22545
commit
a58edfb942
@ -12,24 +12,24 @@ class GildedRose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateQuality() {
|
public void updateQuality() {
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (Item item : items) {
|
||||||
if (items[i].name.equals(AGED_BRIE)) {
|
if (item.name.equals(AGED_BRIE)) {
|
||||||
increaseQualityByOne(items[i]);
|
increaseQualityByOne(item);
|
||||||
} else if (items[i].name.equals(BACKSTAGE_PASSES)) {
|
} else if (item.name.equals(BACKSTAGE_PASSES)) {
|
||||||
increaseQualityBackstage(i);
|
increaseQualityBackstage(item);
|
||||||
} else {
|
} else {
|
||||||
decreaseQualityByOne(items[i]);
|
decreaseQualityByOne(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
decreaseSellInEachDay(items[i]);
|
decreaseSellInEachDay(item);
|
||||||
|
|
||||||
if (items[i].sellIn < 0) {
|
if (item.sellIn < 0) {
|
||||||
if (items[i].name.equals(AGED_BRIE)) {
|
if (item.name.equals(AGED_BRIE)) {
|
||||||
increaseQualityByOne(items[i]);
|
increaseQualityByOne(item);
|
||||||
} else if (items[i].name.equals(BACKSTAGE_PASSES)) {
|
} else if (item.name.equals(BACKSTAGE_PASSES)) {
|
||||||
items[i].quality = 0;
|
item.quality = 0;
|
||||||
} else {
|
} else {
|
||||||
decreaseQualityByOne(items[i]);
|
decreaseQualityByOne(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,13 +41,13 @@ class GildedRose {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void increaseQualityBackstage(int i) {
|
private void increaseQualityBackstage(Item item) {
|
||||||
if (items[i].sellIn < 6) {
|
if (item.sellIn < 6) {
|
||||||
increaseQualityByThree(items[i]);
|
increaseQualityByThree(item);
|
||||||
} else if (items[i].sellIn < 11) {
|
} else if (item.sellIn < 11) {
|
||||||
increaseQualityByTwo(items[i]);
|
increaseQualityByTwo(item);
|
||||||
} else {
|
} else {
|
||||||
increaseQualityByOne(items[i]);
|
increaseQualityByOne(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user