1class Info {
2 private name: string ;
3 constructor(n:string){
4 this.name = n ;
5 };
6 describe(){
7 console.log(`Your name is ${this.name}`);
8 }
9}
10
11const a = new Info('joyous');
12a.describe();
1class Animal {
2 move(distanceInMeters: number = 0) {
3 console.log(`Animal moved ${distanceInMeters}m.`);
4 }
5}
6
7class Dog extends Animal {
8 bark() {
9 console.log("Woof! Woof!");
10 }
11}
12
13const dog = new Dog();
14dog.bark();
15dog.move(10);
16dog.bark();Try