2010-07-29 00:51:35 -04:00
|
|
|
var Animal, Horse, Snake, sam, tom;
|
|
|
|
var __extends = function(child, parent) {
|
|
|
|
var ctor = function(){};
|
2010-02-27 20:12:47 -05:00
|
|
|
ctor.prototype = parent.prototype;
|
|
|
|
child.prototype = new ctor();
|
|
|
|
child.prototype.constructor = child;
|
2010-07-23 12:34:54 -04:00
|
|
|
if (typeof parent.extended === "function") parent.extended(child);
|
2010-08-23 22:08:33 -04:00
|
|
|
child.__super__ = parent.prototype;
|
2010-02-27 20:12:47 -05:00
|
|
|
};
|
2010-07-29 00:51:35 -04:00
|
|
|
Animal = function(_a) {
|
|
|
|
this.name = _a;
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
Animal.prototype.move = function(meters) {
|
|
|
|
return alert(this.name + " moved " + meters + "m.");
|
|
|
|
};
|
|
|
|
Snake = function() {
|
|
|
|
return Animal.apply(this, arguments);
|
|
|
|
};
|
|
|
|
__extends(Snake, Animal);
|
|
|
|
Snake.prototype.move = function() {
|
|
|
|
alert("Slithering...");
|
2010-08-23 22:08:33 -04:00
|
|
|
return Snake.__super__.move.call(this, 5);
|
2010-07-29 00:51:35 -04:00
|
|
|
};
|
|
|
|
Horse = function() {
|
|
|
|
return Animal.apply(this, arguments);
|
|
|
|
};
|
|
|
|
__extends(Horse, Animal);
|
|
|
|
Horse.prototype.move = function() {
|
|
|
|
alert("Galloping...");
|
2010-08-23 22:08:33 -04:00
|
|
|
return Horse.__super__.move.call(this, 45);
|
2010-07-29 00:51:35 -04:00
|
|
|
};
|
|
|
|
sam = new Snake("Sammy the Python");
|
|
|
|
tom = new Horse("Tommy the Palomino");
|
|
|
|
sam.move();
|
|
|
|
tom.move();
|