interface IAnimal {
name: string;
say: () => string;
}
class Animal implements IAnimal {
name: string;
constructor(name: string) {
this.name = name;
}
say() {
return `${this.name} says ${this.phrase}`;
}
}
interface IAnimal {
name: string;
say: () => string;
}
abstract class Animal implements IAnimal {
name: string;
constructor(name: string) {
this.name = name;
}
say() {
return `${this.name} says ${this.phrase}`;
}
protected abstract phrase: string;
}
class Cat extends Animal {
protected get phrase() { return 'm'; }
}
const c = new Cat('q');
console.log(c.say());