Question: Task 1: Soccer Team (2 marks) Create a Python class for the following UML class diagram. Steps: 1. Create an initialiser method (constructor). This is

 Task 1: Soccer Team (2 marks) Create a Python class for

Task 1: Soccer Team (2 marks) Create a Python class for the following UML class diagram. Steps: 1. Create an initialiser method (constructor). This is the __init __) method previously implemented in practical 1. Assign values to the attributes, name, won, lost, draw, score, teamGoals and oppositionGoals. The name attribute can be passed through as a parameter while all other variables can be assigned as 0 . Tip: Recognise that most of the attributes are private, and this will need to be shown within the code. 2. Create and implement the addResult method that updates the values of attributes won, lost, draw, score, teamGoals and oppositionGoals according to the result of the match. For example, if teamGoals parameter is greater than the oppositionGoals parameter, the team won. The attribute teamGoals and oppositionGoals accumulates the number of goals. If the game was won, then 3 points are added to attribute score. If it was a draw, then 1 point. If it was lost, increase the lost attribute by 1. 3. Create and implement the getScore method that returns the value of the private attribute score. 4. Create and implement the goalDifference method that returns the difference of teamGoals and oppositionGoals. 5. Create and implement the printReport method that prints a report of all attributes and its values on the screen. This method should call the goalDifference method. 6. Test your methods by creating an instance of the SoccerTeam class. To do this, execute the following code: seoul = SoccerTeam ("Seoul Dynasty") seoul.printReport() seoul.addResult (2,1) seoul.addResult (2,4) seoul.addResult (,0) seoul.printReport() Your output must match the following: Seoul Dynasty: Won: 0 Lost: 0 Draw: 0 Team Goals: 0 Opposition Goals: 0 Goal Difference: 0 Points: 0 Seoul Dynasty: Won: 1 Lost: 1 Draw: 1 Team Goals: 4 Opposition Goals: 5 Goal Difference: -1 Points: 4

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 Databases Questions!