#include #include /////////Node Class////////// class Player { private: char *PlayerName; ///////Node Data///////// int PlayerScore; ///////////////////////// Player *NextPlayer; // Node Next Pointer///// public: ///// Node Class Constructor////// Player() { PlayerName = ""; PlayerScore = 0; NextPlayer = NULL; } //////Node Class Setter Functions/////// void SetPlayerName(char *P_name) { PlayerName = P_name; } void SetPlayerScore(int P_score) { PlayerScore = P_score; } void SetNextPlayer(Player *P) { NextPlayer = P; } //////Node Class Getter Functions/////// char* getPlayerName() { return PlayerName; } int getPlayerScore() { return PlayerScore; } Player* getNextPlayer() { return NextPlayer; } }; ///// Link List Class//////// class PlayerList { private: Player *CurrentPlayer; Player *HeadPlayer; int Player_Count; int Total_Score; public: PlayerList(); void Add_NewPlayer(char*, int); int ListLength(); void Display(); int getTotalScore(); }; PlayerList::PlayerList() { Player *Pl = new Player(); HeadPlayer = Pl; CurrentPlayer = NULL; Player_Count = 0; Total_Score = 0; } void PlayerList::Add_NewPlayer(char *P_name, int score) { Player *NewPlayer = new Player(); NewPlayer->SetPlayerName(P_name); NewPlayer->SetPlayerScore(score); NewPlayer->SetNextPlayer(NULL); /////When List is empty////// if(CurrentPlayer == NULL) { HeadPlayer = NewPlayer; CurrentPlayer = NewPlayer; } ////When List has some Players/Nodes else CurrentPlayer->SetNextPlayer(NewPlayer); CurrentPlayer = NewPlayer; Player_Count++; Total_Score = Total_Score + NewPlayer->getPlayerScore(); } void PlayerList::Display() { CurrentPlayer = HeadPlayer; cout<<"Player Names " <<'\t'<<"Score " <getPlayerName()<<'\t'<getPlayerScore()<getNextPlayer(); } } int PlayerList::ListLength() { return Player_Count; } int PlayerList::getTotalScore() { return Total_Score; } ////// Main Program/Function///////// main () { PlayerList P_list; P_list.Add_NewPlayer("Muhammad Hafeez", 110); P_list.Add_NewPlayer("Nasir Jamshad", 40); P_list.Add_NewPlayer("Younas Khan", 52); P_list.Add_NewPlayer("Misbaul Haq", 45); P_list.Add_NewPlayer("Umar Akmal", 30); P_list.Add_NewPlayer("Shahid Afridi", 15); P_list.Add_NewPlayer("Umar Gul", 10); P_list.Add_NewPlayer("Saeed Ajmal", 20); cout<<"------Players Records-------" <