Write a class player with attributes name, age and sport. Create methods in the class to set
Fantastic news! We've Found the answer you've been seeking!
Question:
Write a class "player" with attributes "name", "age" and "sport". Create methods in the class to set and get each attribute such as setName(name) and getName() to set and obtain the name of the player's object. Similarly write set and get methods for all the attributes of the class. However, this class is restricted to single sport, so make "sport" variable static.
For example:
Test:
p1 = player("Ronaldo",37)
print(p1.getName())
Result:
Ronaldo
Related Book For
Posted Date: