From f0baec390c4d4ee1a2f975821b5ba4e506817bcb Mon Sep 17 00:00:00 2001 From: "Richard Horton (hortonr6)" Date: Sun, 11 Aug 2019 12:14:49 +0100 Subject: [PATCH] Added a function so that individual squares can be checked outside the grid object --- Grid.cpp | 10 ++++++++++ Grid.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/Grid.cpp b/Grid.cpp index 2ee0c2e..924e780 100644 --- a/Grid.cpp +++ b/Grid.cpp @@ -110,3 +110,13 @@ void Grid::resetGrid() grid[i] = blankGrid[i]; } } + +char Grid::viewSquare(int position) +{ + if(position >= 0 && position <= 8) + { + return this->grid[position]; + } + + return 'F'; +} diff --git a/Grid.h b/Grid.h index 48e027d..5b33f1e 100644 --- a/Grid.h +++ b/Grid.h @@ -12,6 +12,8 @@ class Grid void printGrid(); int checkChoice(char symbol, int input); + char viewSquare(int position); + private: const char blankGrid[9] = {'1', '2', '3', '4', '5', '6', '7', '8', '9'}; // Used to reset the main game grid char grid[9] = {'1', '2', '3', '4', '5', '6', '7', '8', '9'}; // Grid the game is played on and that is displayed to the user