// Game.h // Game class #pragma once #using using namespace System; // Game class definition public __gc class Game { public: // constructor Game(); // destructor ~Game(); // accessors Boolean get_checkOpen( int ); // mutators String *get_board(); //void set_initBoard(); //void set_Move( String *Player, int Position ); private: String *gameBoard[]; }; // Game.cpp // Method definitions for class Game #include "stdafx.h" #include "Game.h" // Game constructor initializes variables to 1-9 Game::Game() { String *gameBoard[] = new String *[9]; gameBoard[0] = "1"; gameBoard[1] = "2"; gameBoard[2] = "3"; gameBoard[3] = "4"; gameBoard[4] = "5"; gameBoard[5] = "6"; gameBoard[6] = "7"; gameBoard[7] = "8"; gameBoard[8] = "9"; } Game::~Game() { } Boolean Game::get_checkOpen( int position_in ) { if( gameBoard[position_in] == "x" || gameBoard[position_in] == "o" ) { return false; } else { return true; } } String *Game::get_board() { Console::WriteLine( gameBoard[0] ); return gameBoard[0]; // this doesn't display ANYTHING, even though I have initialized the gameBoard in the constructor.. what's going on?? } // Assignment02 Comp266 // me /************************************ * * ************************************/ #include "stdafx.h" #include #include "Game.h" #using using namespace System; void displayGrid ( String* array[] ); int _tmain() { Game *objGame = new Game(); // IGNORE EVERYTHING BEFORE THIS LINE FOR NOW ------------------------------------ // displayGrid( objGame->gameBoard[] ); Console::WriteLine( S"Where would you like to move? (1-9): " ); // playerMove( Console::ReadLine(), dispGrid ); return 0; } void displayGrid( String* dispGrid[] ) { Console::WriteLine( S"-------------" ); Console::WriteLine( S"| {0} | {1} | {2} |", dispGrid[0], dispGrid[1], dispGrid[2] ); Console::WriteLine( S"-------------" ); Console::WriteLine( S"| {0} | {1} | {2} |", dispGrid[3], dispGrid[4], dispGrid[5]); Console::WriteLine( S"-------------" ); Console::WriteLine( S"| {0} | {1} | {2} |", dispGrid[6], dispGrid[7], dispGrid[8] ); Console::WriteLine( S"-------------" ); return; }