Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Team {
- string colour;
- int num_of_players;
- int victories;
- int participations_in_competitions;
- public:
- Team();
- Team(string given_colour, int given_num_of_players);
- ~Team();
- string get_colour();
- void set_colour(string str);
- int get_num_of_players();
- void set_num_of_players(int i);
- int get_victories();
- void set_victories(int j);
- int get_participations();
- void set_participations(int z);
- void compete();
- };
- //Constructor with arguments
- Team::Team(){
- colour="";
- num_of_players=0;
- victories=0;
- participations_in_competitions=0;
- }
- //Construstor without arguments
- Team::Team(string given_colour, int given_num_of_players){
- colour=given_colour;
- num_of_players=given_num_of_players;
- victories=0;
- participations_in_competitions=0;
- cout << "The " << colour << " team has initialized." << endl;
- }
- //Destructor
- Team::~Team(){
- cout << "The " << colour << " team has been destroyed." << endl;
- }
- //Seters and geters functions for the 4 variables
- string Team::get_colour(){
- return colour;
- }
- void Team::set_colour(string str){
- colour=str;
- }
- int Team::get_num_of_players(){
- return num_of_players;
- }
- void Team::set_num_of_players(int i){
- num_of_players=i;
- }
- int Team::get_victories(){
- return victories;
- }
- void Team::set_victories(int j){
- victories=j;
- }
- int Team::get_participations(){
- return participations_in_competitions;
- }
- void Team::set_participations(int z){
- participations_in_competitions=z;
- }
- //Methods
- void Team::compete(){
- participations_in_competitions+=1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement