Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The table below shows different types of athletes and their disciplines during competition-runnine. swimming, and biking. Each type of athlete has a fixed set of

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
The table below shows different types of athletes and their disciplines during competition-runnine. swimming, and biking. Each type of athlete has a fixed set of disciplines as is listed in the table with a Y. Specifications 1. Create a Java class called LastNamefirstNameAssignment3 2. Follow "CS1450 Programming Assignments Policy" 3. Write a test program (i.e. main) that performs the following steps: a. Creates a polymorphic array to store the athlete objects. b. For each line in the file athletes.txt: i. Read the information for the athilete. ii. Create an athlete object. iii. Place the athlete object into the array. c. AFTER all athlete objects are in the array, perform these 3 tasks on the array of athletes: L. Find which athletes are bikers ii. Find which athletes do not swim iii. Find the athlete with the slowest running speed For tasks i and in implement the following methods where each method takes the array of all athletes and returns an Arroytist of specific athletes. publie static ArraylisteAthlete) findBikers (Athlete[] athletes) poblic static Arraylisteathletes findoonotSwis (Athlete [I athletes) For task iii implement a method that returns the array index of the slowest runner: public static int findslowesthunner (Athlete[] athletes) NOTE: be sure to place these 3 methods inside the Assignment3 class, right after main. d. Displays on the console the following for each method in step 3c (see output below) Athlete's name Type of athlete (triathlete, duathlete, etc.) Athlete's pace (ONLY for findBikers and findslowestRtunner methods) Athlete's discipline details (use abstract disciplines() method) 4. Test file information: a. Run your code on the provided file athletes.txt b. This file is an example so DONOI assume that your code should work for only 7 athletes in the order specified in the file. 7 t 9.522.8825.84 Dave scott d 8.32023.47 Kenny Souza a 9.012.040 Hannah Kichen m 6.6700 Will Ferrell t 9.573.0026.35 Mark Allen a 8.902.540 Thomas Roos * m 7.0100 George Bush c. 1" line is an integer value representing the number of athletes in the file d. Remaining lines contain details for each athlete. The format is as follows: - Description - Each interface represents a seecitic dikcipine such as nunnine swimming, or biking. - Public Methods - Bunner interface has a method named rund - Returns a double value representing nun speed in mph - Swimmer interface har a method named swimg - Returns a doublo value representine swim speed in mph - Biler interfice has a method named buled - Returns a deublo value representing bave speed in mph Athilete Class - Description - ABSTRACT class thas eepresens a gremeric athiete. - Superdass in the hieranctiy. - Private Data Ilelat - name-Strine for athete's name - Type - String for tipe of athiete fie. Irathilete, Duathiete, efce. - Public Methods - Constructor - nene - Ueike astievmees a 2, secters are provided in the Amlete chass to set the instance varibbles so no constructor is needed in Attlete. - Getter for each data tela - Secter for each dara feld - mBstract method dischplinesd - Aeturss string describing diciptines asociased with a specfic type of achiecte. Triathiete, Duathiete, Aqwathiete, and Marathoner Subclasses - Description Each represents a specific athlete - these are the subclasies in the hierarchy. - A triathlete wili iwim, bite and run during a triathon - A duathlete will run, bile, then poss bly run again during a duathlon - An aquathlete will run, swim, then posubly tun again furing an quathion - A marathoner will fus during a marathat. Each munt entend Athiete. 0. Iach munt implement only the intertaces for the athlete's specific diviglines. - Privahe Data fielar Instance vaciables that represeot the speed asociated with each divcipline the iqecife athiete (subdass) takes part in. - For example, a trathlete neesk a swim speed, nun ypeed, and bike speed. - Public Methods - Constructars - Takes the name of the athlete and the speed values for ONIY the disoplines this trpe of athlete takes part in. For example: Duathlete conctructor takes: name. runspeed and bikespeed. poblic Duathlete (String name, doeble rurbpend, double tibiseed) - Subclass muat imalemen cevty the interfaces for the diciplines that athete performs. - Eample: Duathiete dass only implements Runner and Biker. - This means buathlete must evertide the rund and baleg interface methodt - Each nobians mast oueride the dicciplines? method in the abstract Achlete clans - Use the following strings for the diveiplinet for each type of athlete 6. Note: If run ipeed, seim speed, or blke speed is sero then the athlete does not. particigate is that disclpline (L.t.y ir's not part af their competitios). for example: Aquathktes do not bikr; so, their bike speed ia bet bo 0 . linterfaces and classes Punner, Swimmer, and Biker Interfaces - Description - Publis Methods * Runner inkerface has a method named rund - Peturns a double value representiry ran speed in meh. * Swimmer intertace has a method named swim0 - Retums a double value represerting swim speed in mph * Biker interface has a methos named biked - Aetums a double value representing bike speed in mph Athlete Class * Description - ABSTRACT clars that represents a genenic athlete. - Superclama in the hierarcty. - Private Data Fields - name - String for athlete's name * brpe-string for type of athiete Die. Trathiebe, Duachiete, efc) - Public Methods - Constructor - nene - Unike asigment a2, sesters are provided in the Aeniete clas to let the irstance variables so no constructor is needed in Athlete. - Getter for each data field - Secter for each data field - AEstract method dinciplines] - Refurns string describing disciplnes asociated with a specific type of ashirte. Triathlete, Duathlete, Aowathlete, and Marathoner Subciasses - Description Iach reprevents a specific athlete - theie are the subclawies in the hierarchy. - A triathlebe aff swim, bike and run during a triathlon - A duathlete will run, bibe, then pessibly fun agais dueing a duathlon * An aquathlete will run, saim, then posibly tuf again during an aquathion * A marathoner will nun diring a marathon. 0. Iach mus eutend Athlete. Each munt implement ooly the interfaces for the athlete's ipecific disciplinin. - Private Data Fielda a. Instance variables that represent the speed asociated with each disoline the specific athiete (subclas) takes part in - For enample, a sriathlete needt a swi=t ipeed, nun speed, and bike speed. * Public Methodis - Constructors - Tales the name of the athlete and the speed values for ONir the disciplines this trpe of athiete takes part in. for example: Duathlete comstructor takes: name, runspeed and bikespeed. poblic Duathlete (String naee, donble runspeod, double adiefigeed) - Subdass muat imolement ONtY the interfaces for the daciplines that athlete performa. The table below shows different types of athletes and their disciplines during compection-runnine. swimming, and biking. Each type of athlete has a fixed set of disciplines as is listed in the table with a Y. Specifications 1. Create a Java class called LartNamefirstNameAssignment3 2. Follow "CS1450 Programming Assignments Policy" 3. Write a test program (L.e. main) that performs the following steps: a. Creates a polymoephic array to store the athlete objects. b. For each line in the file athletes.tat: 1. Read the information for the athlete. i. Create an athlete object. i. Place the athlete object into the array. C. AFTER all athlete objects are in the array. perform these 3 tasks an the array of athletes: i. Find which athletes are bikers i. Find which athletes do not swim Wi. Find the athlete with the slowest running speed For tasks i and ii implement the following methods where each method takes the arrax of all athletes and returns an Atranlist of apecific athletes. public static Arraylistcathletes findlikers (Athlete[] athletes) public static Arraycist cathletes fimdoootSoin (athlete [] sthletes) For task iili implement a method that teturns the array index of the slowest runner: public static int findslowesthunner (Athlete[] athletes) NoTE: be sure to place these 3 methods inside the Assignments class, right after main. d. Displays on the console the following for each method in step 3c (see eutput below) Athlete's name Type of athlete (triathlete, duathiete, ete.) Athlete's pace (ONtY for findBikers and findslowesthunner methods) Athlete's discipline detalls (use abstract disciplines: method) 4. Test file information: a. Run your code on the provided file athletes tat. b. This file is an example so DO NOT assume that your code should work for only 7 athletes in the order specified in the file. 7 t 9.522.8825.84 Dave Scott d8.32023.47 Kenny Soura a 9.012.040 Hannah Kitchen m 6.6700 Will Ferrell t 9.573.0026.35 Mark Alien a 8.902.54 O Thomas floos * m 7.01 00 George Bush c. 13 line is an integer value representing the number of athletes in the file d. Remaining lines contain details for each athlete. The format is as follows

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions