Guest User

Untitled

a guest
Sep 17th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3. #include <stdlib.h>
  4. #include "Pokedex.h"
  5. #include "Pokemon.h"
  6.  
  7. #define MAX 10
  8.  
  9. bool initPokedex(tPokedex* p) {
  10. int i=0;
  11. p->v = (tPokedex*) malloc (MAX*sizeof(tPokedex));
  12. if (p == NULL)
  13. return false;
  14. else {
  15. p->tamMax = MAX;
  16. p->numElems = 0;
  17. for (i=0;i<MAX;i++) { //Iniciando a pokedex com nenhum pokemon registrado.
  18. p->v[i].reg = false;
  19. p->v[i].ID = i+1;
  20. }
  21. return true;
  22. }
  23.  
  24. return false;
  25. }
  26.  
  27. // ***********************************************
  28. // *** ***
  29. // ***********************************************
  30. void limparPokedex (tPokedex* p) {
  31. int i;
  32. for (i=0;i<MAX;i++) { //Iniciando a pokedex com nenhum pokemon registrado.
  33. p->v[i].reg = false;
  34. p->v[i].ID = i+1;
  35. }
  36. }
  37.  
  38. // ***********************************************
  39. // *** ***
  40. // ***********************************************
  41. bool inserirPokemon(tPokedex* p, int id) {
  42. p->v[id-1].reg = true;
  43. p->numElems++;
  44. p->v[id-1].ID = id;
  45. printf("Pokemon %d inserido com sucesso\n", id);
  46. return true;
  47. }
  48.  
  49.  
  50. // ***********************************************
  51. // *** ***
  52. // ***********************************************
  53. bool buscarPokemon() {
  54.  
  55. return false;
  56.  
  57. }
  58.  
  59. // ***********************************************
  60. // *** ***
  61. // ***********************************************
  62.  
  63. void imprimirPokedex(tPokedex p) {
  64. int i=0;
  65. while (i<MAX) {
  66. if (p.v[i].reg == true)
  67. printf("Pokemon %d resgistrado\n", p.v[i].ID);
  68. else
  69. printf("Pokemon %d nao registrado\n", p.v[i].ID);
  70. i++;
  71. }
  72. }
  73.  
  74. // ***********************************************
  75. // *** ***
  76. // ***********************************************
  77. int tamPokedex() {
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment