Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CSCI 1302 # Homework A2: Sports N' Stats System Demonstrated proficiency: Inheritance, Polymorphism, Constructors, Overridden Methods, explicit casting, equals and toString methods, Access Specifiers (Protected),
CSCI 1302 # Homework A2: Sports N' Stats System Demonstrated proficiency: Inheritance, Polymorphism, Constructors, Overridden Methods, explicit casting, equals and toString methods, Access Specifiers (Protected), sorting, use of "super" for superclass' constructors and method. Implement the Athlete, Swimmer, Runner, and AthleteTester classes shown Draw an UML diagram with the inheritance relationship of the classes. 1. The Athlete class a. is an abstract class with a single constructor, Athlete (String 1Name, 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. b. Getter and setter methods for the gender of the athlete stored as a char, the Professional status as a boolean. i. the method getIsAPro which returns true if the athletee plays professionally, false is the athlete is amateur. The setIsAPro takes a boolean parameter, true if the athlete is a professional, false if the athlete is an amateur. ii. 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. c. The method computeAge takes no arguments and returns the athletes computed age as of today's date as a string of the form "X years, Y months and Z days". e.g. "21 years, 2 months and 3 days". Hint: Use the LocalDate and Period classes. d. The tostring method returns a string comprised of the results of getFname, getLName, getIsAPro and computeAge. E.g e. 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 false. 2. The Swimmer class a. inherits from the Athlete class and has a single constructor, Swimmer (String 1Name, String fName, int birthYear, int birthMonth, int birthDay. String team). There should be a getter method for team b. The Swimmer class stores swim events for the swimmer. A swimmer participates in one or more of these events. The setEvent method is oveloaded and sets either a single event for the swimmer or set a group of events for the swimmer. Each event is of type String. c. The overridden tostring method returns a string comprised of the concatenation of the parent's toString return plus " swimmer for team: XXXXX in the following events: YYYYY; zzzzzz." 3. The Runner class a. 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 b. The Runner class stores race events for the runner. Each event is of type enum Distance. The list of valid events is given as Add the statement below as a class field. public enum Distance {M100, M200, M400,M3000, M5000, M10000 ; c. A runner participates in one or more of these events. The setEvent method is oveloaded and sets either a single event for the runner or set a group of events for the runner. d. 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 JJJJJJJ and participates in these events: [MX00, MY0O, MZ00]" Complete the code before the due date. Submission of the completed eclipse project is via github link posted on the class page. Add your UML drawing to the github repo. Example output: Example from AthleteDriver shown below 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, 10m freestyle] Usain Bolt is 32 years, 5 months and 30 days and is a professional sprinter from Jamaica and participates in these events: [M160, M20e, 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] public class AthletesTester f public static void main(String[] args) 5 //Create Swimmer Missy Franklin 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"))); //Create Swimmer Naomi Ruele Swimmer s2 new Swimmer(" Ruele", "Naomi", 1997, 1, 13, "Florida International University"); s2.setAPro(false); s2.setEvents (new ArrayList (Arrays.asList("100m backstoke", "50m backstoke", "100m freestyle"))); //Create Runner Usain Bolt Runner r1 = new Runner("Bolt", "Usain", r1.setAPro(true); r1.setEvents (Runner.Distance.M100); r1.setEvents (Runner.Distance.M200); r1.setEvents (Runner.Distance.M400); 1986, 8, 21, "Jamaica"); //Create Runner Florence Griffith Runner r2new Runner("Griffith", "Florence", 1959, 12, 21, "United States of America"); r2.setAPro (true); r2.setEvents (nevw ArrayList (Arrays. asList(Runner. Distance . M10, Runner. Distance . M200)) System.out.println(s1); System.out.println(s2); System.out.println(r1); System.out.println(r2); CSCI 1302 # Homework A2: Sports N' Stats System Demonstrated proficiency: Inheritance, Polymorphism, Constructors, Overridden Methods, explicit casting, equals and toString methods, Access Specifiers (Protected), sorting, use of "super" for superclass' constructors and method. Implement the Athlete, Swimmer, Runner, and AthleteTester classes shown Draw an UML diagram with the inheritance relationship of the classes. 1. The Athlete class a. is an abstract class with a single constructor, Athlete (String 1Name, 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. b. Getter and setter methods for the gender of the athlete stored as a char, the Professional status as a boolean. i. the method getIsAPro which returns true if the athletee plays professionally, false is the athlete is amateur. The setIsAPro takes a boolean parameter, true if the athlete is a professional, false if the athlete is an amateur. ii. 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. c. The method computeAge takes no arguments and returns the athletes computed age as of today's date as a string of the form "X years, Y months and Z days". e.g. "21 years, 2 months and 3 days". Hint: Use the LocalDate and Period classes. d. The tostring method returns a string comprised of the results of getFname, getLName, getIsAPro and computeAge. E.g e. 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 false. 2. The Swimmer class a. inherits from the Athlete class and has a single constructor, Swimmer (String 1Name, String fName, int birthYear, int birthMonth, int birthDay. String team). There should be a getter method for team b. The Swimmer class stores swim events for the swimmer. A swimmer participates in one or more of these events. The setEvent method is oveloaded and sets either a single event for the swimmer or set a group of events for the swimmer. Each event is of type String. c. The overridden tostring method returns a string comprised of the concatenation of the parent's toString return plus " swimmer for team: XXXXX in the following events: YYYYY; zzzzzz." 3. The Runner class a. 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 b. The Runner class stores race events for the runner. Each event is of type enum Distance. The list of valid events is given as Add the statement below as a class field. public enum Distance {M100, M200, M400,M3000, M5000, M10000 ; c. A runner participates in one or more of these events. The setEvent method is oveloaded and sets either a single event for the runner or set a group of events for the runner. d. 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 JJJJJJJ and participates in these events: [MX00, MY0O, MZ00]" Complete the code before the due date. Submission of the completed eclipse project is via github link posted on the class page. Add your UML drawing to the github repo. Example output: Example from AthleteDriver shown below 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, 10m freestyle] Usain Bolt is 32 years, 5 months and 30 days and is a professional sprinter from Jamaica and participates in these events: [M160, M20e, 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] public class AthletesTester f public static void main(String[] args) 5 //Create Swimmer Missy Franklin 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"))); //Create Swimmer Naomi Ruele Swimmer s2 new Swimmer(" Ruele", "Naomi", 1997, 1, 13, "Florida International University"); s2.setAPro(false); s2.setEvents (new ArrayList (Arrays.asList("100m backstoke", "50m backstoke", "100m freestyle"))); //Create Runner Usain Bolt Runner r1 = new Runner("Bolt", "Usain", r1.setAPro(true); r1.setEvents (Runner.Distance.M100); r1.setEvents (Runner.Distance.M200); r1.setEvents (Runner.Distance.M400); 1986, 8, 21, "Jamaica"); //Create Runner Florence Griffith Runner r2new Runner("Griffith", "Florence", 1959, 12, 21, "United States of America"); r2.setAPro (true); r2.setEvents (nevw ArrayList (Arrays. asList(Runner. Distance . M10, 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
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