Advertisement
makispaiktis

Class Team Masterchef

Apr 18th, 2018 (edited)
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7.  
  8.  class Team {
  9.  
  10.      string colour;
  11.      int num_of_players;
  12.      int victories;
  13.      int participations_in_competitions;
  14.  
  15.  
  16.  public:
  17.  
  18.      Team();
  19.      Team(string given_colour, int given_num_of_players);
  20.      ~Team();
  21.  
  22.       string get_colour();
  23.       void set_colour(string str);
  24.       int get_num_of_players();
  25.       void set_num_of_players(int i);
  26.       int get_victories();
  27.       void set_victories(int j);
  28.       int get_participations();
  29.       void set_participations(int z);
  30.  
  31.       void compete();
  32.  };
  33.  
  34.  
  35.    //Constructor with arguments
  36.    Team::Team(){
  37.  
  38.       colour="";
  39.       num_of_players=0;
  40.       victories=0;
  41.       participations_in_competitions=0;
  42.    }
  43.  
  44.  
  45.    //Construstor without arguments
  46.    Team::Team(string given_colour, int given_num_of_players){
  47.  
  48.       colour=given_colour;
  49.       num_of_players=given_num_of_players;
  50.       victories=0;
  51.       participations_in_competitions=0;
  52.  
  53.       cout << "The " << colour << " team has initialized." << endl;
  54.    }
  55.  
  56.  
  57.    //Destructor
  58.    Team::~Team(){
  59.  
  60.        cout << "The " << colour << " team has been destroyed." << endl;
  61.    }
  62.  
  63.  
  64.    //Seters and geters functions for the 4 variables
  65.    string Team::get_colour(){
  66.  
  67.        return colour;
  68.    }
  69.  
  70.    void Team::set_colour(string str){
  71.  
  72.        colour=str;
  73.    }
  74.  
  75.    int Team::get_num_of_players(){
  76.  
  77.        return num_of_players;
  78.    }
  79.  
  80.    void Team::set_num_of_players(int i){
  81.  
  82.        num_of_players=i;
  83.    }
  84.  
  85.    int Team::get_victories(){
  86.  
  87.        return victories;
  88.   }
  89.  
  90.   void Team::set_victories(int j){
  91.  
  92.       victories=j;
  93.   }
  94.  
  95.   int Team::get_participations(){
  96.  
  97.       return participations_in_competitions;
  98.   }
  99.  
  100.   void Team::set_participations(int z){
  101.  
  102.       participations_in_competitions=z;
  103.   }
  104.  
  105.  
  106.   //Methods
  107.   void Team::compete(){
  108.  
  109.       participations_in_competitions+=1;
  110.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement