1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/documentation/js/classes.js

61 lines
1.3 KiB
JavaScript
Raw Normal View History

2012-10-23 16:45:31 -04:00
// Generated by CoffeeScript 1.4.0
2011-12-18 13:41:33 -05:00
var Animal, Horse, Snake, sam, tom,
2012-04-10 14:57:45 -04:00
__hasProp = {}.hasOwnProperty,
2012-05-14 14:45:20 -04:00
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
2010-12-23 15:41:42 -05:00
Animal = (function() {
2010-11-21 12:38:27 -05:00
function Animal(name) {
this.name = name;
}
2010-11-21 12:38:27 -05:00
Animal.prototype.move = function(meters) {
return alert(this.name + (" moved " + meters + "m."));
2010-11-21 12:38:27 -05:00
};
2010-10-19 21:59:13 -04:00
return Animal;
2010-12-23 15:41:42 -05:00
})();
2011-12-18 13:41:33 -05:00
Snake = (function(_super) {
2011-12-18 13:41:33 -05:00
__extends(Snake, _super);
2010-10-19 21:59:13 -04:00
function Snake() {
2012-04-10 14:57:45 -04:00
return Snake.__super__.constructor.apply(this, arguments);
}
2010-11-21 12:38:27 -05:00
Snake.prototype.move = function() {
alert("Slithering...");
return Snake.__super__.move.call(this, 5);
};
2010-10-19 21:59:13 -04:00
return Snake;
2011-12-18 13:41:33 -05:00
})(Animal);
2011-12-18 13:41:33 -05:00
Horse = (function(_super) {
2011-12-18 13:41:33 -05:00
__extends(Horse, _super);
2010-10-19 21:59:13 -04:00
function Horse() {
2012-04-10 14:57:45 -04:00
return Horse.__super__.constructor.apply(this, arguments);
}
2010-11-21 12:38:27 -05:00
Horse.prototype.move = function() {
alert("Galloping...");
return Horse.__super__.move.call(this, 45);
};
2010-10-19 21:59:13 -04:00
return Horse;
2011-12-18 13:41:33 -05:00
})(Animal);
2010-07-29 00:51:35 -04:00
sam = new Snake("Sammy the Python");
2010-07-29 00:51:35 -04:00
tom = new Horse("Tommy the Palomino");
2010-07-29 00:51:35 -04:00
sam.move();
tom.move();