for implementation with abstract class typescript code example
Example 1: ts abstract class
abstract class Person {
name: string;
constructor(name: string) {
this.name = name;
}
display(): void{
console.log(this.name);
}
abstract find(string): Person;
}
class Employee extends Person {
empCode: number;
constructor(name: string, code: number) {
super(name);
this.empCode = code;
}
find(name:string): Person {
return new Employee(name, 1);
}
}
let emp: Person = new Employee("James", 100);
emp.display();
let emp2: Person = emp.find('Steve');
Example 2: abstract classes in typescript
abstract class Animal {
abstract makeSound(): void;
move(): void {
console.log("roaming the earth...");
}
}Try