Question: c++ DIRECTIONS: FIX this code so it builds . try not to change the code too much just change whats causing the problem thats giving

c++

DIRECTIONS: FIX this code so it builds . try not to change the code too much just change whats causing the problem thats giving error codes and not building

code:

#include

using namespace std;

class FootballTeam

{

public:

typedef enum

{

NFC,

AFC

} Conference;

private:

Conference mConference;

string mCity, mName;

int mHomeWins, mHomeLosses, mHomeTies;

int mRoadWins, mRoadLosses, mRoadTies;

public:

FootballTeam();

FootballTeam(Conference, string, string);

Conference getConference()

{

return mConference;

}

string getCity();

string getName();

int getHomewins();

int getHomeLosses();

int getHomeTies();

int getRoadwins();

int getRoadLosses();

int getRoadTies();

void gameScore(int, int, bool);

string homeRecord();

string roadRecord();

string overallRecord();

};

football.cpp

#include "football.h"

#include

#include

FootballTeam::FootballTeam()

{

mConference = NFC;

string mCity = "";

mName = "";

mHomeWins = 0;

mHomeLosses = 0;

mHomeTies = 0;

mRoadWins = 0;

mRoadLosses = 0;

mRoadTies = 0;

}

FootballTeam::FootballTeam(Conference conference, string city, string name)

{

mConference = conference;

string mCity = city;

mName = name;

mHomeWins = 0;

mHomeLosses = 0;

mHomeTies = 0;

mRoadWins = 0;

mRoadLosses = 0;

mRoadTies = 0;

}

string FootballTeam::getCity()

{

return mCity;

}

string FootballTeam::getName()

{

return mName;

}

int FootballTeam::getHomewins()

{

return mHomeWins;

}

int FootballTeam::getHomeLosses()

{

return mHomeLosses;

}

int FootballTeam::getHomeTies()

{

return mHomeTies;

}

int FootballTeam::getRoadwins()

{

return mRoadWins;

}

int FootballTeam::getRoadLosses()

{

return mRoadLosses;

}

int FootballTeam::getRoadTies()

{

return mRoadTies;

}

void FootballTeam::gameScore(int us, int them, bool homeGame)

{

if (homeGame)

{

if (us > them)

mHomeWins++;

else if (us < them)

mHomeLosses++;

else

mHomeTies++;

}

else

{

if (us > them)

mRoadWins++;

else if (us < them)

mRoadLosses++;

else

mRoadTies++;

}

}

string FootballTeam::homeRecord()

{

ostringstream str1;

str1 << mHomeWins << " - " << mHomeLosses << " - " << mHomeTies;

string result = str1.str();

return result;

}

string FootballTeam::roadRecord()

{

ostringstream str1;

str1 << mRoadWins << " - " << mRoadLosses << " - " << mRoadTies;

string result = str1.str();

return result;

}

string FootballTeam::overallRecord()

{

ostringstream str1;

str1 << mHomeWins + mRoadWins << " - " << mHomeLosses + mRoadLosses << " - " << mHomeTies + mRoadTies;

string result = str1.str();

return result;

}

main.cpp

#include

#include

#include

#include "football.cpp"

using namespace std;

bool betterRecord(FootballTeam f, FootballTeam g)

{

int overallWins_f = f.getHomewins() + f.getRoadwins();

int overallLosses_f = f.getHomeLosses() + f.getRoadLosses();

int overallTies_f = f.getHomeTies() + f.getRoadTies();

int overallWins_g = g.getHomewins() + g.getRoadwins();

int overallLosses_g = g.getHomeLosses() + g.getRoadLosses();

int overallTies_g = g.getHomeTies() + g.getRoadTies();

if (overallWins_f > overallWins_g)

return true;

else if (overallWins_f == overallWins_g)

{

if (overallLosses_f < overallLosses_g)

return true;

else if (overallLosses_f == overallLosses_g)

if (overallTies_f > overallTies_g)

return true;

}

return (false);

}

int main()

{

FootballTeam f;

FootballTeam pats(FootballTeam::AFC, "Foxboro", "New England Patriots");

assert(f.getCity() == "");

assert(f.getName() == "");

assert(f.getConference() == FootballTeam::NFC);

assert(f.overallRecord() == "0 - 0 - 0");

assert(f.roadRecord() == "0 - 0 - 0");

assert(f.homeRecord() == "0 - 0 - 0");

pats.gameScore(20, 3, true);

pats.gameScore(20, 40, true);

pats.gameScore(20, 3, false);

pats.gameScore(20, 40, false);

pats.gameScore(20, 20, true);

assert(pats.overallRecord() == "2 - 2 - 1");

assert(pats.roadRecord() == "1 - 1 - 0");

assert(pats.homeRecord() == "1 - 1 - 1");

assert(pats.getHomewins() == 1);

assert(pats.getHomeLosses() == 1);

assert(pats.getHomeTies() == 1);

assert(pats.getRoadwins() == 1);

assert(pats.getRoadLosses() == 1);

assert(pats.getRoadTies() == 0);

assert(betterRecord(pats, f) == true);

assert(betterRecord(f, pats) == false);

assert(betterRecord(pats, pats) == false);

assert(betterRecord(f, f) == false);

cout << "all tests passed!" << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!