Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please finish the following program in java and include a UML diagram. implement the Athlete, Swimmer, Runner, and AthleteTester classes shown. Draw a UML diagram

Please finish the following program in java and include a UML diagram.

implement the Athlete, Swimmer, Runner, and AthleteTester classes shown. Draw a UML diagram with the inheritance relationship of the classes.

  1. The Athlete class
    1. is an abstract class with a single constructor, Athlete(String lName, String fName, int birthyear, int birthMonth, int birthDay). All arguments in the constructor should be stored as class fields. There should only be getter methods for first and last names. There should be no getters or setters for the other fields listed in the constructors.
    2. Getter and setter methods for the gender of the athlete stored as a char, the Professional status as a Boolean.
      1. The method getIsAPro which returns true if the athlete plays professionally, false if the athlete is amateur. The setIsAPro takes a Boolean parameter, true if the athlete is a professional, false if the athlete is an amateur.
      2. The method getGender return either the word male or female or undeclared. The method setGender accepts m, M, f or F which denotes male or female. Any other char will be treated as undeclared.
    3. The method computeAge takes no arguments and returns the athletes computed age as of todays date as a string of the form X years, Y months and Z days. e.g. 21 years, 2 months and 3 days. Use the LocalDate and Period classes.
    4. The toString method returns a string comprised of the results of getFname, getLName, getIsAPro and computeAge.
    5. The equals method returns true if the name and date of birth of this athlete and the compared other athlete are the same, otherwise return fals
  2. The Swimmer class
    1. inherits from the Athlete class and has a single constructor, Swimmer(String lName, String fName, int birthyear, int birthMonth, int birthday, String team). There should be a getter method for team.
    2. The Swimmer class stores swim events for the swimmer. A swimmer participates in one or more of these events. The setEvent method is overloaded and sets either a single event for the swimmer or set a group of events for the swimmer. Each event is of type String.
    3. The overridden toString method returns a string comprimsed of concatenation of the parents toString return plus swimmer for team: XXXXX in the following events: YYYYY; ZZZZZ.
  3. The Runner class
    1. inherits from the Athlete class and has a single constructor, Runner(String lName, String fName, int birthyear, int birthMonth, int birthday, String country). There should be a getter method for country.
    2. The Runner class stores race events for the runner. Each event is of type enum Distance. The list of valid events is given as enumeration.
    3. Add the statement below as a class field.
      1. public enum Distance {M100, M200, M400, M3000, M5000, M10000};
    4. A runner participates in one or more of these events. The setEvent method is overloaded and sets either a single event for the runner or set a group of events for the runner. The toString method returns a String in the form: AAA BBBB is XX years, YY months and ZZ days and is a professional sprinter from JJJJJ and participates in these events: [MX00, MY00, MZ00].

Here is example output:

Missy Franklin is 23 years, 9 months and 10 days and is a professional swimmer for team: Colorado Stars in the following events: [100m backstoke, 200m backstoke, 200m freestyle]

Naomi Ruele is 22 years, 1 months and 7 days and is a amateur swimmer for team: Florida International University in the following events: [100m backstoke, 50m backstoke, 100m freestyle]

Usain Bolt is 32 years, 5 months and 30 days and is a professional sprinter from Jamaica and participates in these events: [M100, M200, M400]

Florence Griffith is 59 years, 1 months and 30 days and is a professional long distance runner from United States of America and participates in these events: [M100, M200]

Here is starter code:

public class AthletesTester {

public static void main(String[] args) {

Swimmer s1 = new Swimmer(Franklin, Missy, 1995, 5, 10, Colorado Stars);

s1.setAPro(true);

s1.setEvents(new ArrayList(Arrays.asList(100m backstoke, 200m backstoke, 200m freestyle)));

Swimmer s2 = new Swimmer(Ruele, Naomi, 1997, 1, 13, Flordia International University);

s2.setAPro(false);

s2.setEvents(new ArrayList(Arrays.asList(100m backstoke, 50m backstoke, 100m freestyle)));

Runner r1 = new Runner(Blot, Usain, 1986, 8, 21, Jamaica);

r1.setApro(true);

r1.setEvents(Runner.Distance.M100);

r1.setEvents(Runner.Distance.M200);

r1.setEvents(Runner.Distance.M400);

Runner r2 = new Runner(Griffith, Florence, 1959, 12, 21, United States of America);

r2.setAPro(true);

r2.setEvents(new ArrayList,Runner.Distance>(Arrays.asList(Runner.Distance.M100,Runner.Distance.M200);

System.out.println(s1);

System.out.println(s2);

System.out.println(r1);

System.out.println(r2);

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

Icdt 88 2nd International Conference On Database Theory Bruges Belgium August 31 September 2 1988 Proceedings Lncs 326

Authors: Marc Gyssens ,Jan Paredaens ,Dirk Van Gucht

1st Edition

3540501711, 978-3540501718

More Books

Students also viewed these Databases questions