Skip to content
Permalink
Browse files
Allowed player and ai classes access to grid object via a pointer
  • Loading branch information
hortonr6 committed Aug 10, 2019
1 parent d0bdcfb commit 2c8cede8d9fe783cec6fd20f77eacad8203cd550
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 AI.cpp
@@ -3,6 +3,10 @@
AI::AI()
{
// Constructor

void AI::setTargetGrid(Grid *grid)
{
gridPtr = grid;
}

void AI::aiTurn()
7 AI.h
@@ -3,10 +3,13 @@

#include <iostream>

#include "Grid.h"

class AI
{
public:
AI();
AI(Grid *grid);

void aiTurn();

@@ -15,12 +18,16 @@ class AI

void setDifficulty();

void setTargetGrid(Grid *grid);

private:
enum difficultyScale{Normal = 1, Impossible = 2};

void normalAITurn();
void impossibleAITurn();

Grid *gridPtr;

int difficulty = 0;
char symbol = ' ';
};
@@ -5,6 +5,11 @@ Player::Player()
// Constructor
}

void Player::setTargetGrid(Grid *grid)
{
gridPtr = grid;
}

void Player::chooseSymbol()
{
// Allows the player to choose whether they are noughts or crosses
@@ -4,10 +4,13 @@
#include <string>
#include <iostream>

#include "Grid.h"

class Player
{
public:
Player();
Player(Grid *grid);

void playerTurn();

@@ -17,9 +20,13 @@ class Player
void setName();
std::string getName();

void setTargetGrid(Grid *grid);

private:
int getInput();

Grid *gridPtr;

std::string name = "";
char symbol = ' ';
};

0 comments on commit 2c8cede

Please sign in to comment.