Refactor: add handleQuality, handleSellIn of item classes

This commit is contained in:
Gayun00 2023-09-25 23:29:27 +09:00
parent 5d670ac672
commit 77c82c95b3
2 changed files with 21 additions and 5 deletions

View File

@ -9,12 +9,14 @@ export class GildedRose {
}
handleSellIn(item) {
//
if (item.name != ITEMS.SURFRAS) {
item.sellIn -= 1;
}
if (item.sellIn >= 0) return;
if (item.quality >= 50) return;
//
switch (item.name) {
case ITEMS.BRIE:
item.quality = item.quality + 1;
@ -29,6 +31,7 @@ export class GildedRose {
}
handlePassesQuality(item) {
//
if (item.name !== ITEMS.PASSES) return;
if (6 <= item.sellIn && item.sellIn < 11) {
item.quality += 1;
@ -40,6 +43,7 @@ export class GildedRose {
}
handleQuality(item) {
//
switch (item.name) {
case ITEMS.PASSES:
this.handlePassesQuality(item);

View File

@ -23,11 +23,12 @@ export class AgedBrie extends Item {
super("Aged Brie", sellIn, quality);
}
handleQuality() {
//
this.quality++;
this.quality++;
}
handleSellIn() {
//
this.sellIn--;
}
}
@ -37,11 +38,20 @@ export class Passes extends Item {
}
handleQuality() {
//
this.quality--;
if (6 <= this.sellIn && this.sellIn < 11) {
this.quality += 1;
}
if (this.sellIn < 6) {
this.quality += 2;
}
this.quality++;
}
handleSellIn() {
//
this.sellIn--;
}
}
@ -50,7 +60,9 @@ export class Surfras extends Item {
super("Sulfuras, Hand of Ragnaros", sellIn, quality);
}
handleQuality() {
//
this.quality = 0;
this.quality--;
this.quality++;
}
handleSellIn() {