Created
November 28, 2016 14:27
-
-
Save rxlabz/fc295072f3b5bfa3a8ecf10e22962d91 to your computer and use it in GitHub Desktop.
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
class Produit{ | |
// private _nom; | |
get nom(){ | |
return this._nom.toUpperCase(); | |
} | |
set nom( value ){ | |
if( value == '') return ; | |
this._nom = value; | |
} | |
get prixHT(){ | |
return this._prixHT + ' €'; | |
} | |
set prixHT(value){ | |
if( value < 0) return ; | |
//this.prixTTC = this._prixHT * (1 + this._tva); | |
this._prixHT = value; | |
} | |
get prixTTC(){ | |
return this._prixHT * (1 + this._tva); | |
} | |
constructor( nom, prixHT ){ | |
this._nom = nom; | |
this._prixHT = prixHT; | |
this._tva = 0.2; | |
//this.prixTTC = this._prixHT * (1 + this._tva); | |
} | |
} | |
var p1 = new Produit('Pain', 1); | |
//p1.prixTTC = 2; | |
console.log(p1.nom, p1.prixHT, p1.prixTTC); | |
p1.prixHT = 0.8; | |
console.log(p1.nom, p1.prixHT, p1.prixTTC); | |
console.log(p1.prixTTC); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment