Skip to content

Instantly share code, notes, and snippets.

@kbuzyk
Created July 16, 2013 17:40
Show Gist options
  • Save kbuzyk/6010884 to your computer and use it in GitHub Desktop.
Save kbuzyk/6010884 to your computer and use it in GitHub Desktop.
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