Question: Please complete this ASAP. Task 1.2 [10 marks] Consider the following class diagram: player_name: string score: list age: integer add_score(l score. integer min_score() add_win() maLscorel)

Please complete this ASAP.

Please complete this ASAP. Task 1.2 [10 marks] Consider the following classdiagram: player_name: string score: list age: integer add_score(l score. integer min_score() add_win()maLscorel) deduct_loss() number_ol'_scores() current_score() get_scores() report_inl'o() We want to create a Score

Task 1.2 [10 marks] Consider the following class diagram: player_name: string score: list age: integer add_score(l score. integer min_score() add_win() maLscorel) deduct_loss() number_ol'_scores() current_score() get_scores() report_inl'o() We want to create a Score Tracker class that will be utilised by the Game class to keep track of all scores. This connector indicates composition. The class on the diamond end will be the container class, and the other object will be contained within, usually as an attribute ofthat class. First, let us create the Score Tracker class. A score tracker makes use of a variable 'scores' which is a list that stores all the recorded scores of the player. These are the requirements of the methods in the Score Tracker class: 0 Create a constructor that adds a default score to the score list. (Note: An empty list can be created by assigning to a variable and values can be added to the list by calling the append!) method.) (2 marks) add_score() receives a new score and adds it to the scores list. (2 marks) min_score{) returns the minimum score in the scores list. (1 mark) mox_score() returns the maximum score in the scores list. number of scores\" returns the total number of scores recorded. number_of_scores() returns the total number of scores recorded. get_scores() prints all the scores on the screen. Test your implementation by executing the following code and show it to your supervisor for marking: new tracker=ScoreTracker (50) new tracker . add_score (60) new tracker . add_score (70) print ( 'Minimum score: ' + str (new tracker . min score () ) ) print ( 'Maximum score: ' + str (new tracker. max_score () ) ) print ( 'Number of scores : ' + str (new tracker . number of scores () ) ) new tracker . get scores () 1.. re to search O m ? . B O ( 1)ENGTask 2.1 (10 marks) We want to update our Game class to make use of the ScoreTracker class and the composition relationship to it. The methods that need to be modified in the Game class are: The constructor must create an instance of ScoreTracker and assigns that instance to a new attribute variable scores. This establishes the relationship between a Game object and a ScoreTracker object. (4 marks) . The method add_win() must add the new score to the tracker object. (2 marks) The method deduct_loss() must add the new score to the tracker object. (2 marks) The report_info() method should print the whole score tracker. (2 marks) Test your implementation with the following code: new game = Game ( 'Berkley' , 30, 50) new_game . add win ( ) new game . deduct_loss () new game . deduct_loss () new game . report info () re to search O 7 ? GO ) ENG

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!