- Crea una clase
Humano
que imprima su nombre y su edad - Crea tres objetos diferentes de la clase
Humano
- Crea una clase
Mexicano
que herede de la claseHumano
e imprima su nacionalidad - Crea tres objetos diferentes de la clase
Mexicano
-
-
Save jorandradefig/24c888e581ff27bf5ded35e9c073ee24 to your computer and use it in GitHub Desktop.
alexfuser
commented
Aug 17, 2017
•
class Humano {
private _name: string;
private _age: number;
constructor (edad: number, nombre: string) {
this._age = edad;
this._name = nombre;
}
sayWhat () {
console.log(`${this._name} tiene ${this._age} años`);
}
getName () {
return this._name;
}
getAge () {
return this._age;
}
}
let j = new Humano(25, "Yair");
let m = new Humano(28, "Cecilia");
let l = new Humano(31, "Lucia");
j.sayWhat();
m.sayWhat();
l.sayWhat();
class Mexicano extends Humano {
private _nac = "mexicana";
constructor (edad: number, nombre: string) {
super(edad, nombre)
}
sayCountry() {
console.log(`${this.getName()} tiene ${this.getAge()} años y es de nacionalidad ${this._nac}`);
}
}
let y = new Mexicano(39, "Yian");
let x = new Mexicano(29, "Xoxi");
let z = new Mexicano(59, "Zan");
y.sayCountry();
x.sayCountry();
z.sayCountry();
class Humano{
name: string;
age: number;
constructor(name:string, age: number){
//console.log(${name} ${age}
)
}
}
var nombreEdad = new Humano("Jorge", 40);
let a = new Humano("Paola",20);
let b = new Humano("Nelly", 23);
let c = new Humano("Berta",21);
class Mexicano extends Humano {
private nacionalidad: string;
constructor (name: string, age: number, nacionalidad:string){
super(name, age)
this.nacionalidad= nacionalidad;
this.age=age;
this.name=name;
}
sayHello(){
console.log(Me llamo ${this.name} y tengo ${this.age} y mi nacionalidad es ${this.nacionalidad} (:
);
}
}
let d = new Mexicano("Berta",21,"mexicana");
d.sayHello();
let e = new Mexicano("Ruben",22,"mexicano");
e.sayHello();
let f = new Mexicano("Berto",24,"mexicano");
f.sayHello();
class Humano {
private _age : number;
private _name : string;
constructor(name: string, age: number){
this._age = age;
this._name = name;
}
Born(){
console.log (`\nName: ${this._name}\nAge: ${this._age}`);
}
}
let aa = new Humano("Nelly", 25);
let bb = new Humano("Alex", 27);
let cc = new Humano("Yong", 27);
aa.Born();
bb.Born();
cc.Born();
class Persona extends Humano {
private nationality : string;
private name: string;
private age: number;
constructor(name:string, age:number, nationality: string){
super(name, age);
this.nationality = nationality;
this.name = name;
this.age = age;
};
Born(){
console.log(`\nName: ${this.name} \nAge: ${this.age}\nNationality: ${this.nationality}`);
}
}
let a = new Persona ("Rolando", 25, "Venezuelan");
let b = new Persona ("Omar", 35, "Mexican");
let c = new Persona ("Carlos", 19, "Colombian");
a.Born();
b.Born();
c.Born();
class Humano {
private _nombre: string;
private _edad: number;
constructor(nombre: string, edad: number){
console.log(${nombre},${edad}
);
this._nombre = nombre;
this._edad = edad;
}
}
let a = new Humano("Paola", 25);
let b = new Humano("Luis", 28);
let c = new Humano("Yesi", 21);
class Mexicano extends Humano {
private _nacionalidad: string;
constructor(nombre: string, edad:number, nacionalidad:string){
super(nombre,edad);
this._nacionalidad = nacionalidad;
console.log(`${nombre},${edad},${nacionalidad}`);
}
}
let d = new Mexicano("Carolina", 36, "Colombiana");
let e = new Mexicano("Roberto", 54, "Brasileño");
let f = new Mexicano("Marcela", 70, "Cubana");
Crea tres objetos diferentes de la clase Humano
Crea una clase Mexicano que herede de la clase Humano e imprima su nacionalidad
Crea tres objetos diferentes de la clase Mexicano */
class Humano {
//Propiedades
private name : string;
private age : number;
//Constructor
constructor(name : string, age : number){
console.log("Humano creado...");
this.name = name;
this.age = age;
}
//Métodos
soyHumano(){
console.log(`Me llamo ${this.name} y tengo ${this.age}, juro que soy un humano totalmente normal con órganos humanos normales`)
}
}
let humano1 = new Humano("Clark Kent", 41);
let humano2 = new Humano("Zim", 21);
let humano3 = new Humano("Hillary", 123);
humano1.soyHumano();
humano2.soyHumano();
humano3.soyHumano();
class Mexicano extends Humano{
private _nacionalidad : string;
private _name : string;
private _age : number;
constructor (_name: string, _age: number, _nacionalidad:string){
super(_name, _age)
this._nacionalidad = _nacionalidad;
this._age = _age;
this._name = _name;
}
soyDe(){
console.log(`Me llamo ${this._name} y tengo ${this._age} y soy del planeta tierra, específicamente de ${this._nacionalidad}`)
}
}
let mexa1 = new Mexicano("José",28,"mexicano");
let mexa2 = new Mexicano("Abril", 26, "México");
let mexa3 = new Mexicano("Erika", 28, "San Diego");
mexa1.soyDe();
mexa2.soyDe();
mexa3.soyDe();
class Humano{
private name: string;
private age: number;
constructor(name:string, age:number){
this.name=name;
this.age=age;
}
sayHello(){
console.log(`me llamo ${this.getName()} y tengo ${this.getAge()}`);
}
setName(name:string){
this.name=name;
}
getName(){
return this.name;
}
setAge(age:number){
this.age=age;
}
getAge(){
return this.age;
}
}
let a = new Humano('Ignacio', 21);
a.sayHello();
let cb = new Humano('Carlos', 31);
cb.sayHello();
let b = new Humano('Jacinto', 12);
b.sayHello();
class Mexicano extends Humano{
private nacionalidad: String;
private name:String;
private age:number;
constructor(name:string, age:number, nacionalidad:string){
super(name,age)
this.nacionalidad=nacionalidad;
this.name=name;
this.age=age;
}
sayHello(){
console.log(Mi nombre es ${this.getName()}, tengo ${this.getAge()} años y mi nacionalidad es ${this.nacionalidad}
);
}
}
let d = new Mexicano('Juan', 21, 'Mexicana' )
d.sayHello();
let e = new Mexicano('Jose', 18, 'Mexicana' )
e.sayHello();
let f = new Mexicano('Luis', 25, 'Mexicana' )
f.sayHello();