Hello, I have worked out a problem to find the winner and second runner up of a marathon.However, I would like to know a more efficient method to get the runner up of the race.Method which I have employed to accomplish this task is to remove the data of the winner of the race and then to determine the winner of our modified list.
Well the object oriented way to do it is to create a class to hold a participant name and their time.
You also make this class implement the Comparable interface.
You then create an instance of this class for each person and add these instances to a List. You then sort this list after which the first entry in the list will be the winner and the second entry will be the runner up.
However, if none of that makes any sense to you yet, then the simple way to do it at the moment is to just add a second pair of variables to hold the name and time of the runner up and then set these in a similar way to how you are currently setting the winner's name and time in the min1 and name1 variables.
Joined: Aug 05, 2005
Edit: Whoops. Meant to edit my previous post, not quote it.