SOURCE

// demo1

// class Animal {
//   move(distance: number = 0) {
//     console.log(`the animal move distance ${distance}m`)
//   }
// }

// class Dog extends Animal {
//   dark() {
//     console.log(`the dog is darking`)
//   }
// }

// let dog = new Dog()
// dog.dark()
// dog.move(100)


// demo2

class Animal {
  name: string;
  constructor(theName: string) {
    this.name = theName;
  }
  move(distance: number = 0) {
    console.log(1)
    console.log(`${this.name} move ${distance}m`)
  }
}

class Snake extends Animal {
  constructor(name: string) {
    super(name)
    console.log(this)
  }
  move(distance = 5) {
    console.log('Snaking...');
    super.move(distance); // 通过super来继承基类的方法
  }
}

class Dog extends Animal {
  constructor(name: string) {super(name)}
  move(distance = 10) {
    console.log('Darking...')
    super.move(distance)
  }
}

let sam = new Snake('snake')
sam.move()




console 命令行工具 X clear

                    
>
console