2009-12-21 11:41:45 -05:00
|
|
|
(function(){
|
2010-02-27 20:12:47 -05:00
|
|
|
var Animal, Horse, Snake, sam, tom;
|
|
|
|
var __extends = function(child, parent) {
|
|
|
|
var ctor = function(){ };
|
|
|
|
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);
|
|
|
|
child.__superClass__ = parent.prototype;
|
2010-02-27 20:12:47 -05:00
|
|
|
};
|
2010-07-23 12:34:54 -04:00
|
|
|
Animal = function() {};
|
2010-05-15 01:18:05 -04:00
|
|
|
Animal.prototype.move = function(meters) {
|
2009-12-21 11:41:45 -05:00
|
|
|
return alert(this.name + " moved " + meters + "m.");
|
|
|
|
};
|
2010-05-15 01:18:05 -04:00
|
|
|
Snake = function(name) {
|
2010-02-13 15:25:04 -05:00
|
|
|
this.name = name;
|
|
|
|
return this;
|
|
|
|
};
|
2010-02-27 20:12:47 -05:00
|
|
|
__extends(Snake, Animal);
|
2010-05-15 01:18:05 -04:00
|
|
|
Snake.prototype.move = function() {
|
2010-02-15 13:55:28 -05:00
|
|
|
alert("Slithering...");
|
|
|
|
return Snake.__superClass__.move.call(this, 5);
|
|
|
|
};
|
2010-05-15 01:18:05 -04:00
|
|
|
Horse = function(name) {
|
2010-02-13 15:25:04 -05:00
|
|
|
this.name = name;
|
|
|
|
return this;
|
|
|
|
};
|
2010-02-27 20:12:47 -05:00
|
|
|
__extends(Horse, Animal);
|
2010-05-15 01:18:05 -04:00
|
|
|
Horse.prototype.move = function() {
|
2010-02-15 13:55:28 -05:00
|
|
|
alert("Galloping...");
|
|
|
|
return Horse.__superClass__.move.call(this, 45);
|
|
|
|
};
|
2009-12-26 02:17:34 -05:00
|
|
|
sam = new Snake("Sammy the Python");
|
|
|
|
tom = new Horse("Tommy the Palomino");
|
2009-12-21 11:41:45 -05:00
|
|
|
sam.move();
|
|
|
|
tom.move();
|
2010-02-24 18:27:10 -05:00
|
|
|
})();
|