diff --git a/OOP/01/Exercise02.cpp b/OOP/01/Exercise02.cpp index c3a2e54..2ead49d 100644 --- a/OOP/01/Exercise02.cpp +++ b/OOP/01/Exercise02.cpp @@ -27,10 +27,13 @@ class ChessPiece { private: bool color; bool isEmptyStatus; + bool isWinStatus; public: void init() { this->isEmptyStatus = true; + this->isWinStatus = false; + this->color = BLACK; } void setColor(bool newColor) { @@ -38,6 +41,10 @@ public: this->color = newColor; } + void setWin() { + this->isWinStatus = true; + } + bool isEmpty() { return this->isEmptyStatus; } @@ -45,12 +52,29 @@ public: bool getColor() { return this->color; } + + std::string show() { + if (this->color == BLACK) { + if (this->isWinStatus) { + return "⬛"; + } + return "⬤"; + } + else { + if (this->isWinStatus) { + return "⬜"; + } + return "◯"; + } + } }; class ChessBoard { private: ChessPiece ChessPieces[15][15]; + int chessCount; + char toHex(int num) { if (num < 10) { return num + '0'; @@ -67,6 +91,7 @@ public: this->ChessPieces[i][j].init(); } } + this->chessCount = 0; } void show() { @@ -89,12 +114,7 @@ public: std::cout << (*emptyLineRef)[j * 2]; } else { - if (this->ChessPieces[i][j].getColor() == BLACK) { - std::cout << "●"; - } - else { - std::cout << "○"; - } + std::cout << this->ChessPieces[i][j].show(); } if (j < 14) { std::cout << (*emptyLineRef)[j * 2 + 1]; @@ -115,6 +135,7 @@ public: return false; } this->ChessPieces[row][column].setColor(color); + this->chessCount++; return true; }