#include #include #include #include #include "BoardT.h" using namespace std; using MyBoardT = BoardT; void BuildBoard(); void PrintBoard(); void MoveBoard(); int main() { cout << "The default size is (" //<< BoardT::Rows() << MyBoardT::Rows() << ", " << BoardT::Cols() << ")" << endl; BoardT::SetSize(10,5); cout << "The new size is (" << BoardT::Rows() << ", " << BoardT::Cols() << ")" << endl; BuildBoard(); PrintBoard(); cout << endl; MoveBoard() ; cout << endl; cout << "After moving the board around." << endl; PrintBoard(); cout << endl; return 0; } void MoveBoard () { // move all odd column values to the left by one. MyBoardT & board = MyBoardT::GetInstance(); size_t r,c; for(r = 0; r < board.Rows(); ++r) { for(c =1; c < board.Cols(); c+= 2) { board.Move(r, c-1, r, c); } } return; } void PrintBoard() { BoardT & board = BoardT::GetInstance(); size_t r,c; for(r = 0 ; r < board.Rows(); ++r) { for(c = 0; c < board.Cols(); ++c) { cout << setw(80/board.Cols()-1) << board[r,c]; } cout << endl; } } void BuildBoard() { ifstream nameFile{"names"}; if (!nameFile) { cout << "Could not open names file. Fail" << endl; return; } BoardT & board = BoardT::GetInstance(); size_t r,c; string name; for(r = 0 ; r < board.Rows(); ++r) { for(c = 0; c < board.Cols(); ++c) { nameFile >> name; board[r,c] = name; } } return; }