Skip to content

Instantly share code, notes, and snippets.

@Vincent-gv
Created December 7, 2018 18:38
Show Gist options
  • Save Vincent-gv/c5b5215bb8947514e4494db34b44a316 to your computer and use it in GitHub Desktop.
Save Vincent-gv/c5b5215bb8947514e4494db34b44a316 to your computer and use it in GitHub Desktop.
Modélisation de plusieurs chiens en POO
var Chien = {
init: function (nom, race, taille) {
this.nom = nom;
this.race = race;
this.taille = taille;
},
aboyer: function () {
var description = " Grrr! Grrr! ";
return description;
}
};
// Renvoie la fonction aboyer
var crokdur = Object.create(Chien);
crokdur.init("Crokdur", "mâtin de Naples", 75);
console.log(crokdur.nom + " est un " + crokdur.race + " mesurant " + crokdur.taille + " cm");
console.log("Tiens, un chat ! " + crokdur.nom + " aboie : " + crokdur.aboyer());
var pupuce = Object.create(Chien);
pupuce.init("Pupuce", "bichon", 22);
console.log(pupuce.nom + " est un " + pupuce.race + " mesurant " + pupuce.taille + " cm");
console.log("Tiens, un chat ! " + pupuce.nom + " aboie : " + pupuce.aboyer());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment