test case added

This commit is contained in:
amanuelMecha 2023-01-05 15:00:12 -05:00
parent 417874249a
commit 2672b4d1ab

View File

@ -11,12 +11,11 @@ class Shop {
this.items = items; this.items = items;
} }
updateQuality() { updateQuality() {
for (let i = 0; i < this.items.length; i++) { this.items.forEach((item) => {
// Set a degradation multiplier to 2 if expiration date has passed // Set a degradation multiplier to 2 if expiration date has passed
// Otherwise set it to 1 (no multiplier) // Otherwise set it to 1 (no multiplier)
let degradationMultiplier = item.sellIn < 0 ? 2 : 1; let degradationMultiplier = item.sellIn < 0 ? 2 : 1;
this.items.forEach((item) => {
switch (item.name) { switch (item.name) {
case "Aged Brie": case "Aged Brie":
item.quality++; item.quality++;
@ -37,7 +36,6 @@ class Shop {
item.quality++; item.quality++;
break; break;
} }
itemSellIn--;
item.sellIn--; item.sellIn--;
break; break;
case "Sulfuras, Hand of Ragnaros": case "Sulfuras, Hand of Ragnaros":
@ -52,63 +50,11 @@ class Shop {
} }
// Item quality cannot be higher than 50 or lower than 0. // Item quality cannot be higher than 50 or lower than 0.
if (itemQuality > 50) itemQuality = 50;
if (itemQuality < 0) itemQuality = 0;
// Use the modified variables to set the actual properties on the item
if (item.quality > 50) item.quality = 50; if (item.quality > 50) item.quality = 50;
if (item.quality < 0) item.quality = 0; if (item.quality < 0) item.quality = 0;
}); });
}
return this.items; return this.items;
// 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].name != 'Sulfuras, Hand of Ragnaros') {
// 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].name == 'Backstage passes to a TAFKAL80ETC concert') {
// if (this.items[i].sellIn < 11) {
// 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;
} }
} }
module.exports = { module.exports = {