There is a Ground class that keeps the ground name and city. There is another class Game, that holds information on game names and the date of the game on which the game will be played. The Player class keeps the information about a Player, name, and code. There is a Team class that holds the team name and the total number of players counted. Using c++
#include <iostream>
#include <string>
using namespace std;
class Ground
{
string name;
string city;
public:
Ground(string _name, string _city)
:name(_name),city(_city){}
void DisplayGrnd()
{
cout << "\nGround name is " << name
<< "\nCity is " << city;
}
};
class Game:public Ground
{
string GameName;
string GameDate;
public:
Game(string _GameName, string _GameDate, string _name, string _city)
:Ground(_name, _city),GameName(_GameName), GameDate(_GameDate){}
void Display()
{
cout << "\nGame name is " << GameName
<< "\nGame date is " << GameDate;
}
};
class Player
{
string info;
string PName;
int code;
public:
Player(){}
Player(string _info, string _PName, int _code)
:info(_info), PName(_PName), code(_code){}
void Display()
{
cout << "\nPlayer`s info is " << info
<< "\nPlayer`s name is " << PName
<< "\nPlayer`s code is " << code;
}
};
class Team
{
string TeamName;
Player* p;
int countPlay;
public:
Team(string _TeamName, Player* _p, int _countPlay)
:TeamName(_TeamName), countPlay(_countPlay)
{
p = new Player[countPlay];
p = _p;
}
void Display()
{
cout << "\nTeam name is " << TeamName;
for (int i = 0; i < countPlay; i++)
{
cout << "\nPlayer " << i + 1 << ":";
p[i].Display();
}
}
};
int main()
{
Game gm("Football", "05.05.2022", "York`s ground", "London");
gm.DisplayGrnd();
gm.Display();
Player arr[3] = { Player("American defender","Peter",12),
Player("English forward","Tomas",9),
Player("French midfielder","Luke",8) };
Team a("Chelsea",arr,3);
a.Display();
}
Comments
Leave a comment