mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 15:01:28 +00:00
Extract updateItemQuality
This commit is contained in:
parent
114efeff62
commit
034fa890cf
@ -6,11 +6,18 @@ class Shop {
|
|||||||
}
|
}
|
||||||
updateQuality() {
|
updateQuality() {
|
||||||
for (var i = 0; i < this.items.length; i++) {
|
for (var i = 0; i < this.items.length; i++) {
|
||||||
this._updateItemQuality(this.items[i]);
|
this._updateItem(this.items[i]);
|
||||||
}
|
}
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateItem(item) {
|
||||||
|
this._updateItemQuality(item);
|
||||||
|
this._updateItemSellIn(item)
|
||||||
|
this._checkMaxQuality(item);
|
||||||
|
this._checkMinQuality(item);
|
||||||
|
}
|
||||||
|
|
||||||
_updateItemQuality(item) {
|
_updateItemQuality(item) {
|
||||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
this._updateQualityBackstagePass(item);
|
this._updateQualityBackstagePass(item);
|
||||||
@ -20,9 +27,6 @@ class Shop {
|
|||||||
} else {
|
} else {
|
||||||
this._updateQualityStandard(item)
|
this._updateQualityStandard(item)
|
||||||
}
|
}
|
||||||
this._updateSellIn(item)
|
|
||||||
this._checkMaxQuality(item);
|
|
||||||
this._checkMinQuality(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateQualityStandard(item) {
|
_updateQualityStandard(item) {
|
||||||
@ -53,7 +57,7 @@ class Shop {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateSellIn(item) {
|
_updateItemSellIn(item) {
|
||||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
item.sellIn = item.sellIn - 1;
|
item.sellIn = item.sellIn - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user