Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #ifndef PECA_H
  2. #define PECA_H
  3. #include <string>
  4.  
  5. using std::string;
  6.  
  7. class Peca {
  8.  
  9. private:
  10. int cor; //0 para as brancas, 1 para as pretas
  11. bool emJogo;
  12.  
  13. public:
  14. Peca(int cor);
  15. string desenha();
  16. bool checaMovimento(int linhaOrigem, int colunaOrigem, int linhaDestino, int colunaDestino);
  17. int getCor();
  18. bool estaEmJogo();
  19. void setForaDeJogo(bool estado);
  20. };
  21. #endif
  22.  
  23. #include "Peca.h"
  24.  
  25. using std::string;
  26.  
  27. class Bispo: public Peca {
  28. public:
  29. Bispo(int cor): Peca(cor);
  30. bool checaMovimento(int linhaOrigem, int colunaOrigem, int linhaDestino, int colunaDestino);
  31. string desenha();
  32. };
  33.  
  34. #include "Bispo.h"
  35. #include <cmath>
  36.  
  37. Bispo::Bispo(int cor): Peca(cor){};
  38.  
  39. bool Bispo::checaMovimento(int linhaOrigem, int colunaOrigem, int linhaDestino, int colunaDestino)
  40. {
  41. if (abs(linhaDestino - linhaOrigem) == abs(colunaDestino - colunaOrigem))
  42. return true;
  43. else
  44. return false;
  45. }
  46.  
  47. //Minúsculo para peças brancas, maiúsculo para as peças pretas
  48. string Bispo::desenha()
  49. {
  50. if(getCor() == 0) // Peça branca
  51. return("b");
  52. else
  53. return("B");
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement