Advertisement
Guest User

crew

a guest
Dec 16th, 2018
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class perro{
  2. constructor(edad,vida,salud){
  3. this.nombre = nombre
  4. this.edad = edad
  5. this.vida = vida
  6. this.salud = salud
  7. }
  8.  
  9. CalcularVida(){
  10. if(this.edad >= 12){
  11. this.vida = this.vida + 10;
  12. }else{
  13. this.vida = this.vida + 20;
  14. }
  15. }else{
  16. if(this.edad <= 12){
  17. this.vida = this.vida + 5;
  18. }else{
  19. this.vida = this.vida + 8;
  20. }
  21. }
  22.  
  23. const Jack = new perro("Jack",12,100,100)
  24.  
  25. Jack.CalcularVida()
  26. console.log(Jack.vida)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement