Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

=+j on to staff their operations in the global marketplace.

Answered: 1 week ago