Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. public class Pokedex implements PokedexInterface{
  2. public Pokedex(int size) {
  3. int length = size;
  4. }
  5. private ArrayList<Pokemon> pokemon = new ArrayList();
  6. public String[] listPokemon() {
  7. if (pokemon.size()> 0){
  8. ArrayList<String> species = new ArrayList();
  9. for (int i = 0; i < pokemon.size(); i++) {
  10. species.add(pokemon.get(i).getSpecies());
  11. }
  12. String pokedex[] = species.toArray(new String[0]);
  13. return pokedex;
  14. }
  15. else {
  16. return null;
  17. }
  18. }
  19. public boolean addPokemon(String species) {
  20. Pokemon next_pokemon = new Pokemon(species);
  21. if (pokemon.size() == XXXX){
  22. return false;
  23. }
  24. for (int i = 0; i < pokemon.size(); i++) {
  25. if (species.equalsIgnoreCase(pokemon.get(i).getSpecies())) {
  26. System.out.println("Duplicate");
  27. return false;
  28. }
  29. }
  30. pokemon.add(next_pokemon);
  31. return true;
  32. }
  33. public int[] checkStats(String species) {
  34. int[] arr = new int[3];
  35. for (int i = 0; i < pokemon.size(); i++) {
  36. if (species.equalsIgnoreCase(pokemon.get(i).getSpecies())) {
  37. arr[0] = pokemon.get(i).getAttack();
  38. arr[1] = pokemon.get(i).getDefense();
  39. arr[2] = pokemon.get(i).getSpeed();
  40. System.out.println();
  41. System.out.println("The stats for " + species + " are:");
  42. System.out.println("Attack: " + arr[0]);
  43. System.out.println("Defense: " + arr[1]);
  44. System.out.println("Speed: " + arr[2]);
  45. return arr;
  46. }
  47. }
  48. System.out.println("Missing");
  49. System.out.println();
  50. return null;
  51. }
  52. public void sortPokedex() {
  53. for (int i = 0; i < pokemon.size() - 1; i++) {
  54. for (int j = 0; j < pokemon.size() - 1; j++) {
  55. if (pokemon.get(j + 1).getSpecies().compareToIgnoreCase(pokemon.get(j).getSpecies()) < 0) {
  56. Collections.swap(pokemon, j, j + 1);
  57. listPokemon();
  58. }
  59. }
  60. }
  61. }
  62. public boolean evolvePokemon(String species) {
  63. String evo = species;
  64. for (int i = 0; i < pokemon.size(); ++i) {
  65. if (pokemon.get(i) != null) {
  66. if (pokemon.get(i).getSpecies().equalsIgnoreCase(species)) {
  67. pokemon.get(i).evolve();
  68. System.out.println(evo + " has evolved!");
  69. return true;
  70. }
  71. }
  72. }
  73. System.out.println("Missing");
  74. return false;
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement