Skip to content

Instantly share code, notes, and snippets.

@rxlabz
Created November 28, 2016 14:27
Show Gist options
  • Save rxlabz/fc295072f3b5bfa3a8ecf10e22962d91 to your computer and use it in GitHub Desktop.
Save rxlabz/fc295072f3b5bfa3a8ecf10e22962d91 to your computer and use it in GitHub Desktop.
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