Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- __bind = function(fn, me){
- return function(){
- return fn.apply(me, arguments);
- };
- },
- __hasProp = {}.hasOwnProperty,
- __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;
- };
- var Animal = (function() {
- function Animal(name) {
- this.name = name;
- this.move = __bind(this.move, this);
- }
- Animal.prototype.move = function(meters) {
- this.position += meters;
- return console.log(this.name + (" moved " + meters + "m."));
- };
- Animal.prototype.position = 0;
- return Animal;
- })();
- var Snake = (function(_super) {
- __extends(Snake, _super);
- function Snake() {
- this.slither = __bind(this.slither, this);
- return Snake.__super__.constructor.apply(this, arguments);
- }
- Snake.prototype.slither = function() {
- return this.move(3);
- };
- return Snake;
- })(Animal);
- var Horse = (function(_super) {
- __extends(Horse, _super);
- function Horse() {
- this.gallop = __bind(this.gallop, this);
- return Horse.__super__.constructor.apply(this, arguments);
- }
- Horse.prototype.gallop = function() {
- return this.move(10);
- };
- return Horse;
- })(Animal);
- var sam = new Snake("Sammy the Python");
- var tom = new Horse("Tommy the Palomino");
- sam.move(1);
- sam.slither();
- tom.gallop();
- console.log("" + sam.name + " moved " + sam.position + "m total");
- console.log("" + tom.name + " moved " + tom.position + "m total");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement