Skip to content

Instantly share code, notes, and snippets.

@imjacobclark
Created February 22, 2014 23:09
Show Gist options
  • Save imjacobclark/9163815 to your computer and use it in GitHub Desktop.
Save imjacobclark/9163815 to your computer and use it in GitHub Desktop.
function Computer(make,model){
this.make = make;
this.model = model;
}
Computer.prototype.switchOn = function(){
console.log("Switching on your " + this.model + ".");
}
Computer.prototype.switchOff = function(){
console.log("Switching off your " + this.model + ".");
}
function OS(version, make, model){
Computer.call(this, make, model);
this.currentVersion = version;
}
OS.prototype = Object.create(Computer.prototype);
OS.prototype.update = function(version){
console.log("Updating your " + this.model + " OS from " + this.currentVersion + " to " + version + ".");
this.completed();
}
OS.prototype.completed = function(){
console.log("Upgrade complete.")
}
var imac = new OS("10.8", "Apple", "iMac");
imac.switchOn();
imac.update("10.9");
imac.switchOff();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment