Commit ad3cf480 by 李楚霏

task-6-subclassing 子类修改测试

parent f8d48a44
export class AgedBrie {
isAgedBrie() {
return 'Aged Brie';
}
isSulfuras() {
return 'Sulfuras, Hand of Ragnaros';
import { Item } from "./item";
}
export class AgedBrie extends Item{
constructor(sell_in, quality){
super(sell_in, quality);
this.name = 'Aged Brie';
};
isBackStage() {
return 'Backstage passes to a TAFKAL80ETC concert';
isAgedBrie() {
return 'Aged Brie';
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@ import { AgedBrie } from "./AgedBrie"
describe('AgedBrieTest', () => {
it('foo', () => {
const agedBrie = new AgedBrie();
const agedBrie = new AgedBrie(2, 0);
const string = agedBrie.isAgedBrie();
expect(string).toEqual('Aged Brie');
})
......
export class BackstagePass {
isAgedBrie() {
return 'Aged Brie';
}
isSulfuras() {
return 'Sulfuras, Hand of Ragnaros';
import { Item } from "./item";
export class BackstagePass extends Item{
constructor(sell_in, quality) {
super(sell_in, quality);
this.name = 'Backstage passes to a TAFKAL80ETC concert';
}
isBackStage() {
return 'Backstage passes to a TAFKAL80ETC concert';
}
......
......@@ -2,7 +2,7 @@ import { BackstagePass } from "./BackstagePass";
describe('backstagePassTest', () => {
it('foo', () => {
const agedBrie = new BackstagePass();
const agedBrie = new BackstagePass(15, 20);
const string = agedBrie.isBackStage();
expect(string).toEqual('Backstage passes to a TAFKAL80ETC concert');
})
......
export class Sulfuras {
isAgedBrie() {
return 'Aged Brie';
import { Item } from "./item";
export class Sulfuras extends Item{
constructor(sell_in, quality) {
super(sell_in, quality);
this.name = 'Sulfuras, Hand of Ragnaros';
}
isSulfuras() {
return 'Sulfuras, Hand of Ragnaros';
}
isBackStage() {
return 'Backstage passes to a TAFKAL80ETC concert';
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@ import { Sulfuras } from "./Sulfuras";
describe('SulfurasTest', () => {
it('foo', () => {
const agedBrie = new Sulfuras();
const agedBrie = new Sulfuras(-1, 80);
const string = agedBrie.isSulfuras();
expect(string).toEqual('Sulfuras, Hand of Ragnaros');
})
......
......@@ -26,11 +26,11 @@ export class Item {
}
createBackStagePass(sell_in, quality) {
new Item('Backstage passes to a TAFKAL80ETC concert', sell_in, quality);
new BackStagePass('Backstage passes to a TAFKAL80ETC concert', sell_in, quality);
}
createSulfuras(sell_in, quality) {
new Item('Sulfuras, Hand of Ragnaros', sell_in, quality);
new Sulfuras(sell_in, quality);
}
createNormalItem(name, sell_in, quality) {
......@@ -38,7 +38,7 @@ export class Item {
}
createAgedBrie(sell_in, quality) {
new Item('Aged Brie', sell_in, quality);
new AgedBrie(sell_in, quality);
}
_updateItem(item) {
......
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