mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Missing logic dissection
This commit is contained in:
parent
79844c8a50
commit
5367b03ff5
@ -34,7 +34,6 @@ class RegularItem extends Item {
|
|||||||
|
|
||||||
const isNameValid = typeof name === 'string' && name.length
|
const isNameValid = typeof name === 'string' && name.length
|
||||||
const isSellInValid = typeof sellIn === 'number'
|
const isSellInValid = typeof sellIn === 'number'
|
||||||
|
|
||||||
// "The Quality of an item is never negative"
|
// "The Quality of an item is never negative"
|
||||||
// "The Quality of an item is never more than 50"
|
// "The Quality of an item is never more than 50"
|
||||||
const isQualityValid = typeof quality === 'number' && quality >= 0 && quality <= 50
|
const isQualityValid = typeof quality === 'number' && quality >= 0 && quality <= 50
|
||||||
@ -98,13 +97,16 @@ class Shop {
|
|||||||
if (this.items[i].name !== 'Backstage passes to a TAFKAL80ETC concert') {
|
if (this.items[i].name !== 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if (this.items[i].quality > 0) {
|
if (this.items[i].quality > 0) {
|
||||||
if (this.items[i].name !== 'Sulfuras, Hand of Ragnaros') {
|
if (this.items[i].name !== 'Sulfuras, Hand of Ragnaros') {
|
||||||
|
// Not cheese, not pass, not sulfuras, therefore regular item
|
||||||
this.items[i].quality = this.items[i].quality - 1
|
this.items[i].quality = this.items[i].quality - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Maybe pass (could be sulfuras), quality is zero because sellIn is negative
|
||||||
this.items[i].quality = this.items[i].quality - this.items[i].quality
|
this.items[i].quality = this.items[i].quality - this.items[i].quality
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Is cheese, increment quality by 1 because sellIn is negative
|
||||||
if (this.items[i].quality < 50) {
|
if (this.items[i].quality < 50) {
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
this.items[i].quality = this.items[i].quality + 1
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user