class Board
1: // Created by Frank M. Carrano and Tim Henry.
2: // Copyright (c) 2013 __Pearson Education__. All rights reserved.
4: /** Listing 5-1.
5: @file Board.h */
6: #ifndef BOARD
7: #define BOARD
9: #include "Queen.h"
10: #include <vector>
11: #include <cassert>
12: #include <iostream>
14: using namespace std;
16: static const int BOARD_SIZE = 8;
18: class Board
19: {
20: private:
21: vector<Queen*> queens; // Array of pointers to queens on the board
22:
23: /** Sees whether a queen exists in position (inRow, inCol). */
24: bool isQueen(int inRow, int inCol) const;
25:
26: /** Attempts to place queens on board, starting with the designated queen. */
27: bool placeQueens(Queen* queenPtr);
28:
29: /** Removes the last queen from the board, but does not deallocate it. */
30: void removeQueen();
31:
32: /** Places a queen on the board. */
33: void setQueen(const Queen* queenPtr);
34:
35: public:
36: /** Supplies the Queen class with a pointer to the board. */
37: Board();
38:
39: /** Clears the board and removes pointer from queens. */
40: ~Board();
41:
42: /** Clears board. */
43: void clear();
44:
45: /** Displays board. */
46: void display() const;
47:
48: /** Initiates the Eight Queens problem. */
49: void doEightQueens();
50:
51: /** @return The number of queens on the board. */
52: int getNumQueens() const;
53:
54: /** @return A pointer to the queen at the designated index. */
55: const Queen* getQueen(int index) const;
56: }; // end Board
57: #endif