class Animal{
name: string
readonly id:string
private age:number
protected son: string
static origin = {x: 0, y: 0}
constructor (theName: string){
this.name = theName
this.son = "张老三"
this.age = 88
this.id = "kfhwifhwkef"
}
get fullName (): string{
return this.name
}
set fullName (newName: string){
this.name = newName
}
move (distanceInMeters: number = 0){
console.log(`${this.name} moved ${distanceInMeters}m.`)
}
}
class Snake extends Animal{
constructor (name: string){
super(name)
}
move (distanceInMeters = 5){
super.move(distanceInMeters)
}
}
let sam = new Snake("Sammy the Python")
sam.move()