Now, implement the following tasks in the main method. • Create a FootballPlayer object p1 of reference type Player with following data values: name="Shahidul Alam", rating = 7.6, goals-10 Create another Football Player object p2 of reference type Player with the following data values: name="Sabrina Khatun", rating-8.9, goals= 15 • Call compare To method to compare p1 and p2. Output the name p1 if compare To 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 changeRating() method of p2 and pass value 8.0.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Define the Player and FootballPlayer classes as described by the UML diagrams below.
#name: String
#rating: double
Player<<abstract>>
#player (name: String, rating: double)
+setName (name:String): void
+setRating (rating:double): void
+getName(): String
+getRating(): double
+changeRating (rating: double): void
+toString(): String
setRating method throws
IllegalArgumentException if rating is
-goals: int
+football Player ( name: String, rating:
double, goals: int)
+setGoals (goals: int): void
+getGoals(): int
+compareTo (Footballplayer obj): int
+changeRating(rating: double): void
+toString(): String
negative
toString method returns all the
value of attributes in this class
FootballPlayer <<extends>> Player implements Comparable <<interface>>
call parent constructor inside its
own constructor
setGoals method throws
IllegalArgumentException if goal is
negative
while implementing the compareTo
method of the interface, compare
the goals with goals of another
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
Transcribed Image Text:Define the Player and FootballPlayer classes as described by the UML diagrams below. #name: String #rating: double Player<<abstract>> #player (name: String, rating: double) +setName (name:String): void +setRating (rating:double): void +getName(): String +getRating(): double +changeRating (rating: double): void +toString(): String setRating method throws IllegalArgumentException if rating is -goals: int +football Player ( name: String, rating: double, goals: int) +setGoals (goals: int): void +getGoals(): int +compareTo (Footballplayer obj): int +changeRating(rating: double): void +toString(): String negative toString method returns all the value of attributes in this class FootballPlayer <<extends>> Player implements Comparable <<interface>> call parent constructor inside its own constructor setGoals method throws IllegalArgumentException if goal is negative while implementing the compareTo method of the interface, compare the goals with goals of another 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 p1 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 compare To method to compare p1 and p2. Output the name p1 if
compare to 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 changeRating() method of p2 and pass value 8.0.
Transcribed Image Text:Now, implement the following tasks in the main method. Create a FootballPlayer object p1 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 compare To method to compare p1 and p2. Output the name p1 if compare to 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 changeRating() method of p2 and pass value 8.0.
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education