#include<iostream>
using namespace std;

const int current_year = 2026;

class athlete{
//// GENEREL ATHLETS' LEVEL

//WORLD GAME INFO
      static const int NO_OF_ATTEMPTS = 5;
      static int world_record;

//CURRENT GAMES  INFO
      static int current_winner;
      static int current_winning_result;

//// SPECIFIC ATHLETE LEVEL
      const int year_of_birth;
      const int id;
      int personal_record;

      int attempts;
      int results[NO_OF_ATTEMPTS];
      int current_max;


   public:
// CONSTRUCTOR
      athlete(int iyb, int iid, int ipr) :
             year_of_birth(iyb), id(iid), personal_record(ipr),
             attempts(0), current_max(0),
             results{}                  // aggregate zero initialization for array -C++11
           { }

// ACCESSORS
      int get_id() const { return id; }
      int get_age() const { return current_year - this->year_of_birth; }
      int get_personal_record() const { return this->personal_record; }


      int get_attempts() const { return this->attempts; }
      int get_current_max() const { return this->current_max; }
      int get_final_result() const { if (this->attempts == NO_OF_ATTEMPTS)
                                         return this->current_max;
                                     else { cout << "Not finished yet! More to go! " << endl;
                                            return -1; }
                                    }
      void print_attempts() const { for(int i = 0; i < this->attempts; i++)
                                       cout << "Attempt :" << i+1 <<
                                               " was " << this->results[i] << " cm " <<
                                               " for athlete: " << this->id << endl; }

//MUTATOR
      void attempt(int result) { if (this->attempts < NO_OF_ATTEMPTS)
                                    { results[this->attempts++] = result;
                                      if (result > this->current_max) this->current_max = result;
                                      if (result > this->personal_record) this->personal_record = result;
                                      if (result > current_winning_result) { current_winning_result = result;
                                                                        current_winner = this->id; }
                                      if (result > world_record) world_record = result;
                                    }
                           }

// STATIC
      static int get_world_record();
      static int get_winner() ;
      static int get_winning_result() ;
};

int athlete::world_record = 850;
int athlete::current_winner = 0;
int athlete::current_winning_result = 0;

int athlete::get_world_record() { return world_record; }
int athlete::get_winner() { return current_winner; }
int athlete::get_winning_result() { return current_winning_result; }

int main(){

   cout << "World Record is: " << athlete::get_world_record() << endl;

   athlete a1(2008, 101, 800);

   cout << "World Record is: " << a1.get_world_record() << endl;  // Remember: it works!

   a1.attempt(700); a1.attempt(750);
   a1.print_attempts();
   cout << "Personal Record for athlete :" << a1.get_id() << " is: " << a1.get_personal_record() << endl;
   cout << "World Record is: " << athlete::get_world_record() << endl;
   cout << a1.get_final_result() << endl;

   a1.attempt(870); a1.attempt(750); a1.attempt(680);
   a1.print_attempts();
   cout << "Personal Record for athlete :" << a1.get_id () << " is: " << a1.get_personal_record() << endl;
   cout << "World Record is: " << athlete::get_world_record() << endl;

   athlete a2(2002,102,850);
   cout << "Personal Record for athlete :" << a2.get_id() << " is: " << a2.get_personal_record() << endl;
   a2.attempt(830); a2.attempt(900); a2.attempt(850);
   a2.attempt(770); a2.attempt(930);
   cout << "Personal Record for athlete :" << a2.get_id() << " is: " << a2.get_personal_record() << endl;
   cout << "World Record is: " << athlete::get_world_record() << endl;
   a2.print_attempts();
   cout << "The best result for athlete " << a2.get_id() << " is " << a2.get_final_result() << endl;


   cout<< "The winner of the games is " << athlete::get_winner()
       << " who achieved first " << athlete::get_winning_result() << endl;
   return 0;
}
 
