1class Person {
2 name: string;
3 age: number;
4
5 walk(): void {
6 console.log('Walking (person Class)')
7 }
8
9 constructor(name: string, age: number) {
10 this.name = name;
11 this.age = age;
12 }
13}
14class child extends Person { }
15
16// Man has to implements at least all the properties
17// and methods of the Person class
18class man implements Person {
19 name: string;
20 age: number
21
22 constructor(name: string, age: number) {
23 this.name = name;
24 this.age = age;
25 }
26
27 walk(): void {
28 console.log('Walking (man class)')
29 }
30
31}
32
33(new child('Mike', 12)).walk();
34// logs: Walking(person Class)
35
36(new man('Tom', 12)).walk();
37// logs: Walking(man class)