interface Habitante{
edad: number,
nombre: String
}
//Tambien se puede poner readonly nombre: String
//las itnerfaces por si solas no sirven solo son una estructura definida que vamos
a hacer que las variables cumplan
class Construccion{
static edificios : number = 0;
constructor(private pisos:number){
Construccion.edificios++;
}
impuestos() : number{
return this.pisos = 3;
}
get pisos():number{
return this._pisos
}
set pisos(pisos:number):number{
this._pisos = pisos;
}
static edificiosCount():number{
return 1;
}
}
class Residencial extends Construccion{
constructor(_pisos: number, private _numeroHabitantes: number){
super(_pisos);//Super obliga a ejecutarse el primer constructor;
}
impuestos(): number{
return this.pisos * 1;
}
get numeroHabitantes():number{
return this._numeroHabitantes;
}
agregarHabitante(habitante: Habitante){
console.log(habitante)
}
}
let oficinasCF = new Construccion(2);
let oficinasGoogle = new Construccion(10);
let oficinasFaceBook = new Construccion(5);
let casaUriel = new Residencial(2,1);
casaUriel.agregarHabitante({nombre:’Uriel’,edad:23});
let Uriel: Habitante = {nombre:’Uriel’,edad:23};
####################################
interface IHabitante{
edad: number,
nombre: String
}
class Hombre implements IHabitante{
constructos(public: String, public edad: number){
}
}