mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-04 09:11:39 +00:00
introduce parameter for item[i]
This commit is contained in:
parent
f2cd52d932
commit
1c56c22545
@ -14,65 +14,65 @@ class GildedRose {
|
|||||||
public void updateQuality() {
|
public void updateQuality() {
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
if (items[i].name.equals(AGED_BRIE)) {
|
if (items[i].name.equals(AGED_BRIE)) {
|
||||||
increaseQualityByOne(i);
|
increaseQualityByOne(items[i]);
|
||||||
} else if (items[i].name.equals(BACKSTAGE_PASSES)) {
|
} else if (items[i].name.equals(BACKSTAGE_PASSES)) {
|
||||||
increaseQualityBackstage(i);
|
increaseQualityBackstage(i);
|
||||||
} else {
|
} else {
|
||||||
decreaseQualityByOne(i);
|
decreaseQualityByOne(items[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
decreaseSellInEachDay(i);
|
decreaseSellInEachDay(items[i]);
|
||||||
|
|
||||||
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(items[i]);
|
||||||
} else if (items[i].name.equals(BACKSTAGE_PASSES)) {
|
} else if (items[i].name.equals(BACKSTAGE_PASSES)) {
|
||||||
items[i].quality = 0;
|
items[i].quality = 0;
|
||||||
} else {
|
} else {
|
||||||
decreaseQualityByOne(i);
|
decreaseQualityByOne(items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decreaseSellInEachDay(int i) {
|
private void decreaseSellInEachDay(Item item) {
|
||||||
if (!items[i].name.equals(SULFURAS)) {
|
if (!item.name.equals(SULFURAS)) {
|
||||||
items[i].sellIn--;
|
item.sellIn--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void increaseQualityBackstage(int i) {
|
private void increaseQualityBackstage(int i) {
|
||||||
if (items[i].sellIn < 6) {
|
if (items[i].sellIn < 6) {
|
||||||
increaseQualityByThree(i);
|
increaseQualityByThree(items[i]);
|
||||||
} else if (items[i].sellIn < 11) {
|
} else if (items[i].sellIn < 11) {
|
||||||
increaseQualityByTwo(i);
|
increaseQualityByTwo(items[i]);
|
||||||
} else {
|
} else {
|
||||||
increaseQualityByOne(i);
|
increaseQualityByOne(items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decreaseQualityByOne(int i) {
|
private void decreaseQualityByOne(Item item) {
|
||||||
if (items[i].quality > 0) {
|
if (item.quality > 0) {
|
||||||
if (!items[i].name.equals(SULFURAS)) {
|
if (!item.name.equals(SULFURAS)) {
|
||||||
items[i].quality--;
|
item.quality--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void increaseQualityByOne(int i) {
|
private void increaseQualityByOne(Item item) {
|
||||||
if (items[i].quality < 50) {
|
if (item.quality < 50) {
|
||||||
items[i].quality++;
|
item.quality++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void increaseQualityByTwo(int i) {
|
private void increaseQualityByTwo(Item item) {
|
||||||
increaseQualityByOne(i);
|
increaseQualityByOne(item);
|
||||||
increaseQualityByOne(i);
|
increaseQualityByOne(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void increaseQualityByThree(int i) {
|
private void increaseQualityByThree(Item item) {
|
||||||
increaseQualityByTwo(i);
|
increaseQualityByTwo(item);
|
||||||
increaseQualityByOne(i);
|
increaseQualityByOne(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user