Docsity

Cricket Player, Score, Statistics System-Applications of Programming-C Plus Plus Code, Exercises of Applications of Computer Sciences

Toggle sidebar
bg1
#include<iostream.h>
#include<conio.h>
/////////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;
}
};
docsity.com
pf3

Partial preview of the text

Download Cricket Player, Score, Statistics System-Applications of Programming-C Plus Plus Code and more Exercises Applications of Computer Sciences in PDF only on Docsity!

#include<iostream.h> #include<conio.h>

/////////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()