-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoard.cpp
57 lines (39 loc) · 1.26 KB
/
Board.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "Board.hpp"
#include <iostream>
Board::Board(char** squareBoard, int size) {
boardSize = size;
board = squareBoard;
}
void Board::initializeBoard() { // set all elements of array to a blank space
for (int row = 0; row < boardSize; row++) {
for (int column = 0; column < boardSize; column++) {
board[row][column] = ' ';
}
}
}
void Board::setSquare(int row, int col, char squareType) {
board[row][col] = squareType;
}
void Board::printBoard(int rowAntOn, int colAntOn) {
for (int i = 0; i < boardSize; i++) {
for (int j = 0; j < boardSize; j++) {
if (i == rowAntOn&& j == colAntOn) {
cout << '@' << " "; // when printing square ant is currently on, print @ instead of # or " "
} else {
cout << board[i][j]; //<< " ";
}
}
cout << endl;
}
/*for (int i = 1; i < boardSize; i++) {
cout << "---" ;
}*/
cout << endl;
//cout << endl;
}
char Board::getSquare(int row, int col) {
return board[row][col];
}
int Board::getSize() {
return boardSize;
}