### Tic Tac Toe game

I am not sure what the convertPosition function is asking? My professor is having us do each function first before attempting the actual game.

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465`` ``````#include #include using namespace std; const bool CLEAR_SCREEN = true; /// @brief Utilizes an escape character sequence to clear the screen void clearScreen() { cout << endl; if (CLEAR_SCREEN) { cout << "\033c"; } cout << endl; } /// @brief Draws the provided tic-tac-toe board to the screen // @param board is the tic-tac-toe board that should be drawn void drawBoard(const vector < char >&board) { clearScreen(); for (int i = 0; i < 9; i += 3) { cout << " " << board.at(i) << " | " << board.at(i + 1) << " | " << board.at(i + 2) << " " << endl; if (i < 6) cout << "-----|-----|-----" << endl; } cout << endl; } /// @brief Fills vector with characters starting at lower case a. /// /// If the vector is size 3 then it will have characters a to c. /// If the vector is size 5 then it will have characters a to e. /// If the vector is size 26 then it will have characters a to z. /// /// @param v the vector to initialize /// @pre-condition the vector size will never be over 26 void initVector(vector &v) { string mapA = "abcdefghijklmnopqrstuvwxyz"; for (int i = 0; i < v.size(); i++) { v.at(i) = mapA.at(i); } } /// @brief Converts a character representing a cell to associated vector index /// @param the position to be converted to a vector index /// @return the integer index in the vector, should be 0 to (vector size - 1) int convertPosition(char position) { // TODO: implement function return -1; } ``````
My quick guess is that you want to convert a to 0, b to 1, and so on. So if someone chooses position d, it is the 4th element in the array (index 3)
Topic archived. No new replies allowed.