Files
linguist/samples/TypeScript/classes.ts
PulsarBlow dc9ad22ec4 TypeScript language support
Signed-off-by: PulsarBlow <pulsarblow@gmail.com>
2013-02-23 23:40:40 +01:00

29 lines
535 B
TypeScript

class Animal {
constructor(public name) { }
move(meters) {
alert(this.name + " moved " + meters + "m.");
}
}
class Snake extends Animal {
constructor(name) { super(name); }
move() {
alert("Slithering...");
super.move(5);
}
}
class Horse extends Animal {
constructor(name) { super(name); }
move() {
alert("Galloping...");
super.move(45);
}
}
var sam = new Snake("Sammy the Python")
var tom: Animal = new Horse("Tommy the Palomino")
sam.move()
tom.move(34)