Question: You are asked to create program that stores running time for all competitors in G oteborgsvarvet (Gothenburg Half Marathon). Create the program according to the

1.2 Thsk 2 Yoe are usked to create program that stores funning time for all coanpetitorn in Gtelongyarvet (Gothenburg Half Marathon). Croate the progrum accerating fo the fallowing reguiremients: Competitor classi 1. Create a clas with the satme Cotmpetitor which should have four instance varablos: (a) natuo (String) (b) age (int) (c) Fender (String) (d) then (Time: a elaes you tood to impleanent) 2. The oonstructor of the elas mbadk take in all fone instance variables: natos, age, gender, and time. 3. You shoeld be able to store Competitor objects uning Serialization, the Compritor objet han a Time object which shotld also be abbe to store using Serielization. 4. Yon'7l need to be able to sort the objects based on the ruaning time, You should inplanent the Comparable interface (comparing two integer values) for this where: Slatal=h3000+m60+n 5. You should Overide the toString() to print out the rexult in the end in followitug format: "H:MM=SS>Name Wist. String. formet (?) Tme class: 1. Create a class with the name Tiew. Thie class should have three instance variables, bours (int), minatas (iat) and acconds (int). 2. The conatractor of the class should take in all three inatance variables hourn, misates and acronds. 3. Nud getter and setter for all inatance variables. 4. You nhould the able to ntore Time objects tusiag Serialisation. Main cluess: 1. You ll got a text file, participanta.txt, inchuding all conapetitors in the Gooteboerovarvet. The file ia structared as "natioe, age synaler", where earlu competitos has its own line in the file Rickourd.37, Made Ansa,28, Feenale The file should be staroxl in your project directary. 2. Create a method callod letsRua(), taking the path (Path) for the participate.txt file as a parameter: The method should return an ArrayList holding Competitor objects. 3. This tnethod should read each line in the file, generate a random time object and create a competitor object for each participant in the file and store it in an ArrayList. The critera for the generated time objects are hours[1,3]minutes[0,59]seconds[0,59]{h,m,s}Z 4. hen all competitors are ereated and stored in the ArrayList, you should sort the ArrayList so the competitor with the shortest running time is listed first and the longest running time last.hen all competitors are created and stored in the ArrayList, you should sort the ArrayList so the competitor with the shortest running time is listod first and the longest running time last, Hint: Collections,sart() 5. Then, you should print the running time results to the console: Figure 8: Running results printed. 6. Finally, twe merialization to store the norted ArrayLivt to a file with the name Running TimeResulteser. This functionality should be implemented in a method called writeToFile() taking the ArrayList with the sorted competitors and the path of "Running TimeResult ser" as a parameters. The program must use at least: - Three classes (the main clas, Competitor class and Time class) - An ArrayList houling the competitor objects. - Comparator interface to sort the objects - Serializable interface (both in Competitor and Time class) - The Main class should have at least three methods; main, letsRun and writeToFile. - The Competitor class should have at least constructor and compareTo(). - The Time class shoukd constructor and getters for all instance variables
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
