运行 ❯
获取你
自己的 Node
服务器
×
更改方向
更改主题,深色/浅色
进入 Spaces
interface Shape { getArea: () => number; } class Rectangle implements Shape { public constructor(protected readonly width: number, protected readonly height: number) {} public getArea(): number { return this.width * this.height; } } class Square extends Rectangle { public constructor(width: number) { super(width, width); } // getArea gets inherited from Rectangle } const mySq = new Square(20); console.log(mySq.getArea());
400