Given the successful compilation the program should run with the command line instruction:

./Football n a1 m1 d1 a2 m2 d2

where n is the number of games to be played. The value of n should be between 1 and 99 inclusive. The other parameters specify the number of players of different types in the team.

The structure of the simulation is such that two football teams will play n games against each other during the lifetime of the program. There are only two teams and they will be referred to as team1 and team2 in this specification. You need to store information about the records of the teams and the games they have played, specifically:

  • The team names. These can be randomly generated or fixed.
  • The number of games played.
  • Games won by each team.
  • Games drawn.
  • Goals by each team.
  • A record of all games played.
  • Spending by each team. Initially $0.

The heart of the simulation is in the people who play and look after the teams. Every person have a name and an age, these can be randomly generated, with the age being in a sensible range. People have various skills, as specified below. Each skill is in the range 1 to 100, with 100 the best and 1 the worst, and can never go outside those ranges.

There are three different support staff associated with each team.

  • A coach who trains players between games. Based on their skill rating they should have a chance to increase player skills.
  • A physio who is responsible for helping players to recover health in between games, to a degree dependent on their skill and the gap between games.
  • An accountant who updates the overall financial information of the team day by day.

Players themselves have a skill associated with their health, and start the tournament with health 100. There are four different types of players: attackers, midfielders, defenders and goalkeepers. You should give the players skills that appropriately represent how they interact during the game. You can assume that attackers and midfields contribute to the attack of a team and may score, while midfielders, defenders and goalkeepers contribute to the defence of a team. Midfielders may well have unrelated abilities as regards defending and attacking.

Each team has exactly 1 goalkeeper and a total of 11 players. The number of players of different types for each team are as specified by the command line parameters; so a1;m1; d1 as the number of attackers, midfielders and defenders, respectively, for team one; and a2;m2; d2 the analogous fields for team two. Bad data for a team, in particular not specifying a total of 10, should result in 3, 4, 3 being used. There are no reserves for the teams.

Initial skills ratings for staff and players should be randomly chosen in appropriate ranges, other than health. Skill ratings for staff don't change, but may for players. Daily salaries don't change, and should also be randomly chosen over what you consider a suitable range.

Here goes the basic structure of your program. You need to write whatever functions and data members you require to support a simulation which runs through as follows.

These teams play n games but the games are separated by 2-5 days each. There will always be a game on Day 1 of the simulation. On each non{playing day there are the following events.

  • Accountants add the daily salaries of staff and players to the team spending.
  • Coaches attempt to improve the skill(s) of their players.
  • Physios help improve the health of their players.

On a playing day a game is played. The result should be determined by you to be a reasonable function of the skills, including the health, of the players. You also ...

  • Accountants add the daily salaries of staff and players to the team spending.
  • Each player loses some health through playing. They should be losing enough that it will typically take 3 or 4 days of rest to recover completely, although a good physio will help with this. If there is a long tournament players will likely be run down by the end.
  • Each player has a small chance of increasing their skill. Increases should be appropriately rare.

The following is appropriate for output:

  • At the start of the tournament list the skills for the staff of each team.
  • Display the day number on every day.
  • If it is a game day:
    • Display the players in each team before the game starts; including ratings of the players.
    • Display the outcome of the game, and the in{game action if you decide you need some.
    • Display the players in each team after the game finishes; including ratings of the players.
    • Display a summary of the team1 vs team2 tournament to date, without listing the results of all the games.
  • At the end of any day you should display the financial spending of each team.
  • At the end of the simulation display the overall result of the tournament and a list of all game results.

All output should be concise, for example one line per player, but clear.

Other than the initial command line input, the program should run without prompting. Thus we expect to be able to type

./Football 4 2 4 4 4 3 3 > Output.txt

and have the output all in Output.txt.

You should spend some time play-testing to make sure you get somewhat sensible results. Thus 20-0 as a game result might be fine if you have a team with ratings in the 80s vs one in 20s, but it shouldn't be a common result for balanced teams.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.