forked from mouredev/hello-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects.js
More file actions
45 lines (37 loc) · 982 Bytes
/
Copy pathobjects.js
File metadata and controls
45 lines (37 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class Persona {
constructor(nombre, edad, nacionalidad ) {
this.nombre = nombre;
this.edad = edad;
this.nacionalidad = nacionalidad;
}
saludar(){
console.log("hola mi nombre es: "+this.nombre + " y mi nacionalidad : " + this.nacionalidad);
}
}
const persona1 = new Persona("Mario ",27,"Mexicano");
const persona2 = new Persona("Juan ",28,"Colombiano");
console.log(persona1);
console.log(persona2);
persona2.saludar();
class Animal {
constructor(nombre, tipo){
this.nombre = nombre;
this.tipo = tipo;
}
saluda(){
console.log(`hola soy ${this.nombre} `);
}
habla(){
console.log("Ruido de animal");
}
}
class Perro extends Animal {
constructor(nombre,tipo, raza){
super(nombre,tipo);
this.raza = raza;
}
habla(){ console.log("los perros ladran ");}
}
const perro1 = new Perro("will","perro","dogo")
console.log(perro1);
perro1.habla();