• Source
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. class Board;
    5. class Piece
    6. {
    7. public:
    8. Piece(bool w, string t) : _type(t),_isWhite(w) {}
    9. Piece() {}
    10. Piece(Piece & other) : _type(other._type), _isWhite(other._isWhite) {}
    11. bool isChass(bool, Board*) { return false; }
    12. virtual int move(int x_src, int y_src, int x_dst, int y_dst, Board* board)=0;
    13. virtual ~Piece() {}
    14. bool get_isWhite() {return _isWhite;}
    15. string get_type() {return _type; }
    16. Piece& operator= (const Piece & other) { _type=other._type; _isWhite=other._isWhite;}
    17. bool inRange(int, int) { return true; }
    18.  
    19. protected:
    20. bool _isWhite;
    21. string _type;
    22. };
    23.  
    24. class Blank : public Piece {
    25. public:
    26. Blank() {}
    27. int move(int x_src, int y_src, int x_dst, int y_dst, Board* board) override {
    28. return 0;
    29. }
    30. };
    31.  
    32. class Board
    33. {
    34. public:
    35. Board();
    36. Board(const Board& other);
    37. ~Board();
    38. Board& operator=(const Board &other);
    39. Piece& getPiece(int i, int j){ return *_board[i][j]; }
    40. void game();
    41. void deletePiece(int x, int y) { delete _board[x][y]; }
    42. void allocateBlankPiece(int x, int y) { _board[x][y] = new Blank(); }
    43.  
    44. private:
    45. Piece*** _board;
    46. bool _isWhiteTurn;
    47. };
    48.  
    49. int main() {
    50. // your code goes here
    51. return 0;
    52. }