-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
34 lines (30 loc) · 727 Bytes
/
app.ts
File metadata and controls
34 lines (30 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Human {
name: string;
constructor(name: string){
this.name = name;
}
eat(){
console.log(this.name + " is a Human and is eating");
}
}
class Robot {
name:string;
constructor(name:string){
this.name = name;
}
}
class Animal {
name:string;
constructor(name:string){
this.name = name;
}
eat(){
console.log(this.name + " is a Human and is eating");
}
}
let r: Robot = new Robot("R2-D2");
let r0: Robot = new Animal("Donkey");//how is this possible?
var isItRobot = r0 instanceof Robot;
console.log("Is Donkey a Robot: " + isItRobot);//false, giving the right results
let h: Human = new Human("Tom");
console.log(h.eat());