From 034fa890cf0239cfaeddd0b9532ee6041dbfeb75 Mon Sep 17 00:00:00 2001 From: Dan Holmes Date: Thu, 3 Dec 2020 15:29:11 +0000 Subject: [PATCH] Extract updateItemQuality --- js-jasmine/src/shop.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/js-jasmine/src/shop.js b/js-jasmine/src/shop.js index af529387..9bd50b6f 100644 --- a/js-jasmine/src/shop.js +++ b/js-jasmine/src/shop.js @@ -6,11 +6,18 @@ class Shop { } updateQuality() { for (var i = 0; i < this.items.length; i++) { - this._updateItemQuality(this.items[i]); + this._updateItem(this.items[i]); } return this.items; } + _updateItem(item) { + this._updateItemQuality(item); + this._updateItemSellIn(item) + this._checkMaxQuality(item); + this._checkMinQuality(item); + } + _updateItemQuality(item) { if (item.name == 'Backstage passes to a TAFKAL80ETC concert') { this._updateQualityBackstagePass(item); @@ -20,9 +27,6 @@ class Shop { } else { this._updateQualityStandard(item) } - this._updateSellIn(item) - this._checkMaxQuality(item); - this._checkMinQuality(item); } _updateQualityStandard(item) { @@ -53,7 +57,7 @@ class Shop { } } - _updateSellIn(item) { + _updateItemSellIn(item) { if (item.name != 'Sulfuras, Hand of Ragnaros') { item.sellIn = item.sellIn - 1; }