// Utilisation d'un accesseur

class Qui {
    private _nom:string;
    private _prenom:string;
    private _age:number;

    constructor( nom:string, prenom:string, age:number ) {
        this._nom = nom;
        this._prenom = prenom;
        this._age = age;
    }    

    get nom() {
        return this._nom;
    }

    get prenom() {
        return this._prenom;
    }

    get age() {
        return this._age;
    }

    set age(valeur:number ) {
        if ( valeur > 0 && valeur < 120 )
            this._age = valeur;
    }

}

const adupont : Qui = new Qui( "dupont", "albert", 44 );
console.log( adupont.nom );
console.log( adupont.prenom );
console.log( adupont.age );
// adupont.nom = "dupont2";    // Interdit
// adupont._nom = "dupont2";   // Interdit
adupont.age = 0;
console.log( adupont.age );







