mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add snapshot of release-1.0.3 sources
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
===== TypeScript Sample: Simple =====
|
||||
|
||||
=== Overview ===
|
||||
|
||||
Simple use of classes and inheritance:
|
||||
- Classes: A base class and two subclasses
|
||||
- Super calls: Derived classes make super calls
|
||||
|
||||
|
||||
=== Running ===
|
||||
tsc animals.ts
|
||||
@@ -0,0 +1,26 @@
|
||||
class Animal {
|
||||
constructor(public name) { }
|
||||
move(meters) {
|
||||
alert(this.name + " moved " + meters + "m.");
|
||||
}
|
||||
}
|
||||
|
||||
class Snake extends Animal {
|
||||
move() {
|
||||
alert("Slithering...");
|
||||
super.move(5);
|
||||
}
|
||||
}
|
||||
|
||||
class Horse extends Animal {
|
||||
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)
|
||||
Reference in New Issue
Block a user