Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. package javaapplication1;
  2. //Cambiar PACKAGE
  3. public class Pokemon
  4. {
  5. private String nombre;
  6. private int nivel;
  7. private int vida;
  8. private String tipo;
  9.  
  10. public Pokemon(String nombre, int nivel, int vida, String tipo) {
  11. setNombre(nombre);
  12. setNivel(nivel);
  13. setVida(vida);
  14. setTipo(tipo);
  15. }
  16.  
  17. public Pokemon() {
  18. }
  19.  
  20. public String getNombre() {
  21. return nombre;
  22. }
  23.  
  24. public void setNombre(String nombre) {
  25. this.nombre = nombre;
  26. }
  27.  
  28. public int getNivel() {
  29. return nivel;
  30. }
  31.  
  32. public void setNivel(int nivel) {
  33. if(nivel==1||nivel==2||nivel==3)
  34. this.nivel = nivel;
  35. }
  36.  
  37. public int getVida() {
  38. return vida;
  39. }
  40.  
  41. public void setVida(int vida) {
  42. this.vida = vida;
  43. }
  44.  
  45. public String getTipo() {
  46. return tipo;
  47. }
  48.  
  49. public void setTipo(String tipo) {
  50. if(tipo.equals("Fuego")||tipo.equals("Agua")||tipo.equals("Hierba"))
  51. this.tipo = tipo;
  52. }
  53.  
  54. public String datosPokemon(){
  55. return "Pokemon{" + "nombre=" + nombre + ", nivel=" + nivel + ", vida=" + vida + ", tipo=" + tipo + '}';
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement