mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-04 09:11:39 +00:00
instance method
This commit is contained in:
parent
da6f6ffd5b
commit
4a96b36ac3
@ -11,31 +11,7 @@ class GildedRose {
|
|||||||
public void updateQuality() {
|
public void updateQuality() {
|
||||||
for (Item item : items) {
|
for (Item item : items) {
|
||||||
|
|
||||||
if (item.isAgedBrie()) {
|
item.updateQuality();
|
||||||
item.increaseQualityByOne();
|
|
||||||
|
|
||||||
item.decreaseSellInEachDay();
|
|
||||||
|
|
||||||
if (item.sellIn < 0) {
|
|
||||||
item.increaseQualityByOne();
|
|
||||||
}
|
|
||||||
} else if (item.isBackstagePasses()) {
|
|
||||||
item.increaseQualityBackstage();
|
|
||||||
|
|
||||||
item.decreaseSellInEachDay();
|
|
||||||
|
|
||||||
if (item.sellIn < 0) {
|
|
||||||
item.quality = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
item.decreaseQualityByOne();
|
|
||||||
|
|
||||||
item.decreaseSellInEachDay();
|
|
||||||
|
|
||||||
if (item.sellIn < 0) {
|
|
||||||
item.decreaseQualityByOne();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,34 @@ public class Item {
|
|||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateQuality() {
|
||||||
|
if (isAgedBrie()) {
|
||||||
|
increaseQualityByOne();
|
||||||
|
|
||||||
|
decreaseSellInEachDay();
|
||||||
|
|
||||||
|
if (sellIn < 0) {
|
||||||
|
increaseQualityByOne();
|
||||||
|
}
|
||||||
|
} else if (isBackstagePasses()) {
|
||||||
|
increaseQualityBackstage();
|
||||||
|
|
||||||
|
decreaseSellInEachDay();
|
||||||
|
|
||||||
|
if (sellIn < 0) {
|
||||||
|
quality = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
decreaseQualityByOne();
|
||||||
|
|
||||||
|
decreaseSellInEachDay();
|
||||||
|
|
||||||
|
if (sellIn < 0) {
|
||||||
|
decreaseQualityByOne();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isBackstagePasses() {
|
public boolean isBackstagePasses() {
|
||||||
return name.equals(BACKSTAGE_PASSES);
|
return name.equals(BACKSTAGE_PASSES);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user