Answer:
Following are the class definition to this question:
class Player//defining a Player class
{
private://use access specifier
string name;//defining string variable
int score;//defining integer variabl
public://use access specifier
void setName(string par_name);//declaring the setName method with one string parameter
void setScore(int par_score);//declaring the setScore method with one integer parameter
string getName();//declaring string method getName
int getScore();//declaring integer method getScore
};
Step-by-step explanation:
In the above-given code, a Player class is defined, that hold a method and the variable which can be defined as follows:
- It uses two access specifier, that are public and private.
- In private, a string and an integer variable "name, score" is declared, which holds their respective value.
- In public, it declares the get and set method, which holds the value from its parameters.