Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef PECA_H
- #define PECA_H
- #include <string>
- using std::string;
- class Peca {
- private:
- int cor; //0 para as brancas, 1 para as pretas
- bool emJogo;
- public:
- Peca(int cor);
- string desenha();
- bool checaMovimento(int linhaOrigem, int colunaOrigem, int linhaDestino, int colunaDestino);
- int getCor();
- bool estaEmJogo();
- void setForaDeJogo(bool estado);
- };
- #endif
- #include "Peca.h"
- using std::string;
- class Bispo: public Peca {
- public:
- Bispo(int cor): Peca(cor);
- bool checaMovimento(int linhaOrigem, int colunaOrigem, int linhaDestino, int colunaDestino);
- string desenha();
- };
- #include "Bispo.h"
- #include <cmath>
- Bispo::Bispo(int cor): Peca(cor){};
- bool Bispo::checaMovimento(int linhaOrigem, int colunaOrigem, int linhaDestino, int colunaDestino)
- {
- if (abs(linhaDestino - linhaOrigem) == abs(colunaDestino - colunaOrigem))
- return true;
- else
- return false;
- }
- //Minúsculo para peças brancas, maiúsculo para as peças pretas
- string Bispo::desenha()
- {
- if(getCor() == 0) // Peça branca
- return("b");
- else
- return("B");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement