Commit 1e689b2d by 李楚霏

task10--调整子类;增加新的conjured子类

parent 24efc7bd
...@@ -6,12 +6,12 @@ export class AgedBrie extends Item { ...@@ -6,12 +6,12 @@ export class AgedBrie extends Item {
this.name = 'Aged Brie' this.name = 'Aged Brie'
} }
updateQuality(item) { updateQuality() {
if (item.quality < 50) { if (this.quality < 50) {
item.quality = item.quality + 1 this.quality = this.quality + 1
} }
} }
updateQualityAfterExpired(item) { updateQualityAfterExpired() {
return return
} }
isAgedBire() { isAgedBire() {
......
...@@ -9,24 +9,24 @@ export class BackstagePass extends Item{ ...@@ -9,24 +9,24 @@ export class BackstagePass extends Item{
isBackStage() { isBackStage() {
return true return true
} }
updateQuality(item) { updateQuality() {
if (item.quality >= 50) { if (this.quality >= 50) {
return return
} }
if (item.sell_in < 11) { if (this.sell_in < 11) {
if (item.quality < 50) { if (this.quality < 50) {
item.quality = item.quality + 1 this.quality = this.quality + 1
} }
} }
if (item.sell_in < 6) { if (this.sell_in < 6) {
if (item.quality < 50) { if (this.quality < 50) {
item.quality = item.quality + 1 this.quality = this.quality + 1
} }
} }
} }
updateQualityAfterExpired(item) { updateQualityAfterExpired() {
if (item.quality < 50) { if (this.quality < 50) {
item.quality = item.quality + 1 this.quality = this.quality + 1
} }
} }
} }
import { Item } from './item'
export class Conjured extends Item {
constructor(sell_in, quality) {
super(sell_in, quality)
this.name = 'Conjured'
}
updateQuality() {}
updateQualityAfterExpired() {
this.quality -= 2
}
isConjured() {
return true
}
}
import { Item } from './item' import { Item } from './item'
export class Sulfuras extends Item{ export class Sulfuras extends Item {
constructor(sell_in, quality) { constructor(sell_in, quality) {
super(sell_in, quality) super(sell_in, quality)
this.name = 'Sulfuras, Hand of Ragnaros' this.name = 'Sulfuras, Hand of Ragnaros'
...@@ -9,11 +9,11 @@ export class Sulfuras extends Item{ ...@@ -9,11 +9,11 @@ export class Sulfuras extends Item{
isSulfuras() { isSulfuras() {
return true return true
} }
updateQuality(item) {} updateQuality() {}
updateQualityAfterExpired(item) { updateQualityAfterExpired() {
return return
} }
updateSellIn(item) { updateSellIn() {
return return
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment