Typescript - 1

by tgundogdu

TypeScript

class Ogrenci {
    adi: string;
    soyadi: string;
    yas: number;
    boy: number;
    cinsiyet: string = 'Kadın';

    constructor(adi: string,soyadi:string, yas:number, boy:number,cinsiyet:string) {
        this.adi = adi;
        this.soyadi = soyadi;
        this.yas = yas;
        this.boy = boy;
        this.cinsiyet = cinsiyet;
    }
    mesaj() {
        return "Merhaba " + this.adi + ' ' + this.soyadi + ', Yaşın ' + this.yas + ', Boyun ' +
            this.boy + ' ve Cinsiyetin ' + this.cinsiyet;
    }
    idealKilo() {
        return this.boy / 2 - 10;
    }
}


let ogrenci = new Ogrenci('Tevrat', 'Gündoğdu', 29, 175,'Erkek');
alert(ogrenci.mesaj());
alert(ogrenci.idealKilo());