MCPcopy Create free account
hub / github.com/SincereCSL/Playgrounds / Cat

Class Cat

TypeScript/StudyTypeScript/src/class_02.ts:11–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9// let animal = new Animal() // 不能够实例化,只能被继承
10
11class Cat extends Animal{
12 constructor(name: string) {
13 super()
14 this.name = name
15 }
16 name: string
17 run() {}
18 sleep() {
19 console.log('cat sleep')
20 }
21}
22let cat = new Cat('喵喵')
23cat.eat()
24cat.sleep()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected