mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
replaced main for loop in updateQuality method with for.. of
This commit is contained in:
parent
dc038c3f11
commit
aeae3bbdc3
@ -18,47 +18,47 @@ export class GildedRose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateQuality() {
|
updateQuality() {
|
||||||
for (let i = 0; i < this.items.length; i++) {
|
for (const item of this.items) {
|
||||||
if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
if (item.name != 'Aged Brie' && item.name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if (this.items[i].quality > 0) {
|
if (item.quality > 0) {
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
this.items[i].quality = this.items[i].quality - 1
|
item.quality = item.quality - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.items[i].quality < 50) {
|
if (item.quality < 50) {
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
item.quality = item.quality + 1
|
||||||
if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
|
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if (this.items[i].sellIn < 11) {
|
if (item.sellIn < 11) {
|
||||||
if (this.items[i].quality < 50) {
|
if (item.quality < 50) {
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
item.quality = item.quality + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.items[i].sellIn < 6) {
|
if (item.sellIn < 6) {
|
||||||
if (this.items[i].quality < 50) {
|
if (item.quality < 50) {
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
item.quality = item.quality + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
this.items[i].sellIn = this.items[i].sellIn - 1;
|
item.sellIn = item.sellIn - 1;
|
||||||
}
|
}
|
||||||
if (this.items[i].sellIn < 0) {
|
if (item.sellIn < 0) {
|
||||||
if (this.items[i].name != 'Aged Brie') {
|
if (item.name != 'Aged Brie') {
|
||||||
if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
if (item.name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if (this.items[i].quality > 0) {
|
if (item.quality > 0) {
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
this.items[i].quality = this.items[i].quality - 1
|
item.quality = item.quality - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.items[i].quality = this.items[i].quality - this.items[i].quality
|
item.quality = item.quality - item.quality
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.items[i].quality < 50) {
|
if (item.quality < 50) {
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
item.quality = item.quality + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user