Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Board::Board(int c1r, int c1c, int c2r, int c2c) {
- cout << "Enter the size of the board between 9 and 12\n";
- cin >> boardSize;
- if (!validSize(boardSize)) {
- cout << "Invalid Entered Size\n";
- exit(1);
- }
- board = new char* [boardSize];
- for (int i = 0; i < boardSize; i++) {
- *(board + i) = new char[boardSize];
- }
- for (int i = 0; i < boardSize; i++) {
- for (int j = 0; j < boardSize; j++) {
- *(*(board + i) + j) = '-';
- }
- }
- *(*(board + c1r) + c1c) = 'C';
- *(*(board + c2r) + c2c) = 'C'; // Represents the two cats
- *(*(board + (boardSize / 2)) + boardSize - 1) = 'B'; // Assuming that when there are two rows which is middle, we take the least one
- }
- Board::~Board() {
- for (int i = 0; i < boardSize; i++) {
- delete[] * (board + i);
- }
- delete[] board;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement