#pragma once
#include <iostream>
#include "Flag.h"
usingnamespace std;
class Referee
{
private:
int totalFlags;
public:
Referee()
{
totalFlags = 0;
};
~Referee()
{
};
void watchPlay()
{
int random = rand() % 100 + 1;
if (totalFlags > 2)
{
//I'm supposed to read these flags that I'm making in this method in my FootballGame class
if (random <= 20)
{
Flag* flag = new Flag("Holding", "Offense",-10);
totalFlags++;
}
if (random > 20 && random <= 40)
{
Flag* flag = new Flag("Offsides", "Defense", 5);
totalFlags++;
}
}
};
};
#pragma once
#include <iostream>
#include "Play.h"
#include "Referee.h"
#include "Flag.h"
usingnamespace std;
class FootballGame
{
private:
Referee* referee;
public:
FootballGame();
int runPlay(Play *play)
{
referee->watchPlay();
//Here's where I need the flags to be read, but I'm not sure how I can do it. I was planning on using the if/else statements in some way, but I don't necessarily need to use them.
if ( )
{
//If a flag is created in the Referee Class, I need to read it here.
//I have a toString() method in my Flag class that I need to use in order to read it here.
}
else
{
return 0;
}
};
~FootballGame()
{
delete referee;
//delete Flag*;
}
};
I figured out that a try/catch block is what I'm supposed to do, rather than a if/else statement. Now I'm just trying to make it try the referee->watchPlay() part and catch the flag. Still having some trouble, but I'm getting closer.