forked from thejsway/thejsway_fr-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
70 additions
and
196 deletions.
There are no files selected for viewing
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
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()); |
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
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()}`); | ||
|
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
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()); | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.