面试题答案
一键面试// 创建接口Shape
interface Shape {
color: string;
draw(): void;
}
// 创建类Circle实现Shape接口
class Circle implements Shape {
color: string;
radius: number;
constructor(color: string, radius: number) {
this.color = color;
this.radius = radius;
}
draw(): void {
console.log(`绘制一个半径为${this.radius},颜色为${this.color}的圆`);
}
}