Created
July 16, 2013 17:40
-
-
Save kbuzyk/6010884 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Creature = (function () { | |
// constructor | |
function Creature (name) { | |
// public properties | |
this.name = name; | |
this.extremities; | |
this.isBird; | |
} | |
// private properties | |
var bones; | |
// public methods | |
Creature.prototype.walk = function () { | |
for (var i = 0; i < this.extremities; i++) { | |
console.log(i+1+" leg ahead."); | |
} | |
} | |
Creature.prototype.breathe = function () { | |
_heartbeat(); | |
} | |
Creature.prototype.fly = function () { | |
console.log((!this.isBird) ? "Can't fly, just jump." : "Fly!") | |
} | |
Creature.prototype.eat = function (food) { | |
console.log(this.name + " eats " + food) | |
} | |
// private methods | |
function _heartbeat () { | |
console.log("tap-tap-tap"); | |
} | |
return Creature; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment