Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Solve using Java Define the Player and FootballPlayer classes as described by the UML diagrams below. Player> #name: String setRating method throws #rating: double IllegalArgumentException
Solve using Java
Define the Player and FootballPlayer classes as described by the UML diagrams below. Player> #name: String setRating method throws #rating: double IllegalArgumentException if rating is negative #player (name: String , rating: double) toString method returns all the +setName (name:String): void value of attributes in this class tsetRating (rating:double): void +getName(): String +getRatingo): double +change Rating (rating: double): void +toString: String FootballPlayer > Player implements Comparable > -goals: int call parent constructor inside its own constructor +footballPlayer ( name: String, rating: setGoals method throws double, goals: int) IllegalArgumentException if goal is +setGoals (goals: int): void negative +getGoals(): int while implementing the compareTo + compareTo (Footballplayer obj): int method of the interface, compare +changeRating(rating: double): void the goals with goals of another +toString(: String FootballPlayer obj: return 1 if the number of class goals is greater than that of obj goals, else return 0 - while implementing the abstract method of the parent class, set the rating of the parent class to the rating value from the parameter list. toString method returns all the data field including parent attributes should be returned Now, implement the following tasks in the main method. Create a FootballPlayer object pl of reference type Player with following data values: name = "Shahidul Alam", rating = 7.6, goals= 10 Create another FootballPlayer object p2 of reference type Player with the following data values: name="Sabrina Khatun, rating=8.9, goals= 15 Call compareTo method to compare p1 and p2. Output the name p1 if compareTo method return 1 else output p2 name. Set rating of object pl as -5. Catch with appropriate error messages if any exception occurs here. Invoke change Rating() method of p2 and pass value 8.0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started