Created
December 7, 2018 18:38
-
-
Save Vincent-gv/c5b5215bb8947514e4494db34b44a316 to your computer and use it in GitHub Desktop.
Modélisation de plusieurs chiens en POO
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 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