Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class perro{
- constructor(edad,vida,salud){
- this.nombre = nombre
- this.edad = edad
- this.vida = vida
- this.salud = salud
- }
- CalcularVida(){
- if(this.edad >= 12){
- this.vida = this.vida + 10;
- }else{
- this.vida = this.vida + 20;
- }
- }else{
- if(this.edad <= 12){
- this.vida = this.vida + 5;
- }else{
- this.vida = this.vida + 8;
- }
- }
- const Jack = new perro("Jack",12,100,100)
- Jack.CalcularVida()
- console.log(Jack.vida)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement