mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 07:51:29 +00:00
comment legacy version and add switch statement
This commit is contained in:
parent
9abbf056d6
commit
28ed899f66
@ -5,57 +5,75 @@ class Item {
|
|||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO: You just started using the switch statement and increment variables. Uncomment the bottom code and run the tests to see the last working version.
|
||||||
class Shop {
|
class Shop {
|
||||||
constructor(items=[]){
|
constructor(items=[]){
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
updateQuality() {
|
updateQuality() {
|
||||||
|
|
||||||
for (let i = 0; i < this.items.length; i++) {
|
for (let i = 0; i < this.items.length; i++) {
|
||||||
if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
|
||||||
if (this.items[i].quality > 0) {
|
// Initialize two incrementers. These will change based on various factors below.
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
let sellInIncrement = 0;
|
||||||
this.items[i].quality = this.items[i].quality - 1;
|
let qualityIncrement = 0;
|
||||||
}
|
|
||||||
}
|
switch (this.items[i].name) {
|
||||||
} else {
|
case 'Aged Brie':
|
||||||
if (this.items[i].quality < 50) {
|
console.log('Aged Brie')
|
||||||
this.items[i].quality = this.items[i].quality + 1;
|
qualityIncrement++
|
||||||
if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
|
break;
|
||||||
if (this.items[i].sellIn < 11) {
|
case 'Backstage passes to a TAFKAL80ETC concert':
|
||||||
if (this.items[i].quality < 50) {
|
console.log('Backstage passes to a TAFKAL80ETC concert')
|
||||||
this.items[i].quality = this.items[i].quality + 1;
|
break;
|
||||||
}
|
default:
|
||||||
}
|
console.log('default!')
|
||||||
if (this.items[i].sellIn < 6) {
|
|
||||||
if (this.items[i].quality < 50) {
|
|
||||||
this.items[i].quality = this.items[i].quality + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
this.items[i].sellIn = this.items[i].sellIn - 1;
|
// if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
}
|
// if (this.items[i].quality > 0) {
|
||||||
if (this.items[i].sellIn < 0) {
|
// if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
if (this.items[i].name != 'Aged Brie') {
|
// this.items[i].quality = this.items[i].quality - 1;
|
||||||
if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
// }
|
||||||
if (this.items[i].quality > 0) {
|
// }
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
// } else {
|
||||||
this.items[i].quality = this.items[i].quality - 1;
|
// if (this.items[i].quality < 50) {
|
||||||
}
|
// this.items[i].quality = this.items[i].quality + 1;
|
||||||
}
|
// if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
} else {
|
// if (this.items[i].sellIn < 11) {
|
||||||
this.items[i].quality = this.items[i].quality - this.items[i].quality;
|
// if (this.items[i].quality < 50) {
|
||||||
}
|
// this.items[i].quality = this.items[i].quality + 1;
|
||||||
} else {
|
// }
|
||||||
if (this.items[i].quality < 50) {
|
// }
|
||||||
this.items[i].quality = this.items[i].quality + 1;
|
// if (this.items[i].sellIn < 6) {
|
||||||
}
|
// if (this.items[i].quality < 50) {
|
||||||
}
|
// this.items[i].quality = this.items[i].quality + 1;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
|
// this.items[i].sellIn = this.items[i].sellIn - 1;
|
||||||
|
// }
|
||||||
|
// if (this.items[i].sellIn < 0) {
|
||||||
|
// if (this.items[i].name != 'Aged Brie') {
|
||||||
|
// if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
|
// if (this.items[i].quality > 0) {
|
||||||
|
// if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
|
// this.items[i].quality = this.items[i].quality - 1;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// this.items[i].quality = this.items[i].quality - this.items[i].quality;
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// if (this.items[i].quality < 50) {
|
||||||
|
// this.items[i].quality = this.items[i].quality + 1;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user