Skip to content

Commit

Permalink
Add chapter 6 exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
bpesquet committed Dec 11, 2018
1 parent 33f56e3 commit 9cae0aa
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 196 deletions.
24 changes: 24 additions & 0 deletions chapitre6_exercice1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Expérience du personnage

const aurora = {
nom: "Aurora",
sante: 150,
force: 25,
xp: 0,

// Renvoie la description du personnage
decrire() {
return `${this.nom} a ${this.sante} points de vie, ${
this.force
} en force et ${this.xp} points d'expérience`;
}
};

// "Aurora a 150 points de vie, 25 en force et 0 points d'expérience"
console.log(aurora.decrire());

console.log("Aurora apprend une nouvelle compétence");
aurora.xp += 15;

// "Aurora a 150 points de vie, 25 en force et 15 points d'expérience"
console.log(aurora.decrire());
19 changes: 19 additions & 0 deletions chapitre6_exercice2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Modélisation d'un chien

const chien = {
nom: "Crockdur",
race: "mâtin de Naples",
taille: 75,

// Renvoie l'aboiement du chien
aboyer() {
return "Grrr ! Grrr !";
}
};

// "Crockdur est un mâtin de Naples mesurant 75"
console.log(`${chien.nom} est un ${chien.race} mesurant ${chien.taille} cm`);

// "Tiens, un chat ! Crockdur aboie : Grrr ! Grrr !"
console.log(`Tiens, un chat ! ${chien.nom} aboie : ${chien.aboyer()}`);

27 changes: 27 additions & 0 deletions chapitre6_exercice3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Modélisation d'un compte bancaire

const compte = {
titulaire: "Alex",
solde: 0,

// Ajoute un montant au solde
crediter(montant) {
this.solde += montant;
},

// Renvoie la description du compte
decrire() {
return `titulaire: ${this.titulaire}, solde: ${this.solde}`;
}
};

// "titulaire: Alex, solde: 0"
console.log(compte.decrire());

compte.crediter(250);
compte.crediter(-80);

// "titulaire: Alex, solde: 170"
console.log(compte.decrire());


13 changes: 0 additions & 13 deletions chapitre_7/html/cercle.html

This file was deleted.

13 changes: 0 additions & 13 deletions chapitre_7/html/chien.html

This file was deleted.

13 changes: 0 additions & 13 deletions chapitre_7/html/compte.html

This file was deleted.

13 changes: 0 additions & 13 deletions chapitre_7/html/cours.html

This file was deleted.

13 changes: 0 additions & 13 deletions chapitre_7/html/jdr.html

This file was deleted.

23 changes: 0 additions & 23 deletions chapitre_7/js/cercle.js

This file was deleted.

17 changes: 0 additions & 17 deletions chapitre_7/js/chien.js

This file was deleted.

30 changes: 0 additions & 30 deletions chapitre_7/js/compte.js

This file was deleted.

31 changes: 0 additions & 31 deletions chapitre_7/js/cours.js

This file was deleted.

30 changes: 0 additions & 30 deletions chapitre_7/js/jdr.js

This file was deleted.

0 comments on commit 9cae0aa

Please sign in to comment.