Question: In swift language do the following: Create a class called Player that properly implements CustomStringConvertible . This class has two private properties: name and score.
In swift language do the following:
- Create a class called Player that properly implements CustomStringConvertible . This class has two private properties: name and score. The name cannot change once set but score can. The initializer should take in the players name as a parameter. Set the score to zero in the initializer.
- The computed property that CustomStringConvertible forces implementation of should return names current score is XX where name is the name of the player and XX is their score. Add a method to the class called addToScore. This method should take in one parameter, amount, which is the amount that should be added to the score.
- Create a < function that compares two players. The < function should return true if the score of the left Player object is less than the score of the right Player object.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
