Hi there ppl, im about to create a soccer game for my project in c++, but I dont really know how to get it started,could anyone help me with this,any help will be appreciated.thnx.
these are precise step i have to include in the project.
(1) set up a league table with the number of teams (say 4 for simplicity)
set up the struct league
set up a dynamic array of numTeams for the league
write a function to enter all the team names and set all the other variables
to 0
(2) set up a composite struct called e.g. TeamsPlayedOrNot
set up an array of size numTeams
you will enter each team and the corresponding information for the teams
they will play and whether they have played or not. This team information
will be got from the league table teams. You should try to do this
automatically. Set playedOrNot to false
This information will be used to decide what teams have played
against each other. See part 3
(3) Its now time to play a match!!!!!!!
Look up a main team and a team they must play against. Ensure that a team hasn’t played a match. You can print out the teams that hav’nt played for the given team and the position in the inner array. You need to set playedOrNot to true.
Collect the information required for the league match and update these details into the league for each corresponding teams. Also enter these details into the TeamsPlayedOrNot array for the second team
(4) It is now time to sort the league table in order from the highest score to the lowest
score. You can use a selection sort/bubble sort- some simple sort
this is some code i have done so far,its working,but this is not exactly the thing i am looking for:
#include <iostream>
#include <iomanip>
#include <string>
#include <stdio.h>
using namespace std;
struct TeamInfo
{
char name[15];
int teamID;
int numOfWins;
int numOfDraws;
int numOfLosses;
int goalsFwd;
int goalsAgn;
int numTimesPlayed;
int totalScore;
};
double total = 0;
int main()
{
const int SIZE = 2;
TeamInfo soccer[SIZE];
cout << "Enter the team information below\n";
cout << "----------------------------------\n";
for(int i = 0; i < SIZE; i++)
{
cout << "\nEnter team number " << (i + 1) << " name: " << endl;
cin >> soccer[i].name;
cout << "\nEnter number of wins: " << endl;
cin >> soccer[i].numOfWins;
cout << "\nEnter number of draws: " << endl;
cin >> soccer[i].numOfDraws;
cout << "\nEnter number of losses: " << endl;
cin >> soccer[i].numOfLosses;
cout << "\nEnter goals forward: " << endl;
cin >> soccer[i].goalsFwd;
cout << "\Enter goals against: " << endl;
cin >> soccer[i].goalsAgn;
cout << "\nEnter number of times played: " << endl;
cin >> soccer[i].numTimesPlayed;
while( soccer[i].teamID < 0 )
{
cout << "Please enter a number greater than zero: ";
cin >> soccer[i].teamID;
}
cout << "\nEnter the number of points scored by team #" << (i+1) << ": " << endl;
cin >> soccer[i].totalScore;
while(soccer[i].totalScore < 0)
{
cout << "Please enter a number greater than zero: ";
cin >> soccer[i].totalScore;
}
}
system("pause");
//std::cout << "Total points combined are: \n";
//std::cout << fixed << showpoint << setprecision(2);
for(int i = 0; i < SIZE; i++)
{
total = soccer[i].totalScore + total;
}
cout << "The total score combined for the team: " << total << endl;
int max = 0;
for(int i = 0; i < SIZE; i++)
{
if(soccer[i].totalScore > max)
{
max = soccer[i].totalScore;
}
}
for(int i = 0; i < SIZE; i++)
{
if(soccer[i].totalScore == max)
{
cout << "The team that got the highest number of points is: " << soccer[i].name << endl;
}
}
system("pause");
return 0;
}