92.2k views
2 votes
Write the definition of a class Player containing:

(a) An instance variable name of type String, initialized to the empty String.
(b) An instance variable score of type int, initialized to zero.
(c) A method called set_name that has one parameter, whose value it assigns to the instance variable name.
(d) A method called set_score that has one parameter, whose value it assigns to the instance variable score.
(e) A method called get_name that has no parameters and that returns the value of the instance variable name.
(f) A method called get_score that has no parameters and that returns the value of the instance variable score.

User Norio
by
4.7k points

1 Answer

6 votes

Answer:

The definition of class Player is given in attached image with all its parts covered.

Each part in briefed by comments before the statements.

The code is written in python.

Write the definition of a class Player containing: (a) An instance variable name of-example-1
User Christophe Henry
by
4.3k points