/Users/adamklas/Desktop/IB/Net Beans/Dossier for Ms. Boughey/src/dossier/pkgfor/ms/boughey/BestScores.java
  1 /*
  2  * To change this license header, choose License Headers in Project Properties.
  3  * To change this template file, choose Tools | Templates
  4  * and open the template in the editor.
  5  */
  6 package dossier.pkgfor.ms.boughey;
  7 
  8 import java.util.ArrayList;
  9 import java.util.Calendar;
 10 
 11 /**
 12  *
 13  * @author adamklas
 14  */
 15 public class BestScores {
 16 
 17     public String[] classBestScore(ArrayList<Student> studentList, String blockToSearch, String category) {
 18         //Firstly I sort the Array List of students received
 19         //for description refer to SortAndSearch.java lines 18-47
 20         int n = studentList.size();
 21         boolean sorted = false;
 22         while (!sorted) {
 23             n--;
 24             sorted = true;
 25             for (int i = 0; i < n; i++) {
 26                 if (studentList.get(i).getStudentBlock().compareTo(studentList.get(i + 1).getStudentBlock()) > 0) {
 27                     Student temp = studentList.get(i); //making a temporary carList object
 28                     studentList.set(i, studentList.get(i + 1)); //set first to be the second
 29                     studentList.set(i + 1, temp);//set the second to be the temp
 30                     sorted = false;
 31 
 32                 }
 33             }
 34         }
 35         //I establish an empty Array List, which will contain the selected Students 
 36         ArrayList<Student> blockToSearchList  = new ArrayList();
 37 
 38         //here I loop through all the Students in the Array List received
 39         for (int i = 0; i < studentList.size(); i++) {
 40             //if the class/block of the student is equal to the one selected by the user
 41             if (studentList.get(i).getStudentBlock().equals(blockToSearch)) {
 42                 //the Student is added to selection Array List, created before
 43                 blockToSearchList.add(studentList.get(i));
 44             }
 45         }
 46         //sort new array and take last student's score (top score)
 47 
 48         //Here I make and instance of the bestTrial class
 49         BestTrial bestTrial = new BestTrial();
 50         //Integer "n1" is set to be the size of the Array List of selected Students
 51         int n1 = blockToSearchList.size();
 52         //initial "sorted1" is set to be false to start
 53         boolean sorted1 = false;
 54 
 55         
 56         
 57         //Now I go through the categories, and for each category the same come is carried out
 58         //With the exception of the 1.5k run (lines 253 - 262)
 59         if (category.equals("Shotput")) {
 60 
 61             //While "sorted1" is false the loop keeps repeating
 62             while (!sorted1) {
 63                 n1--;
 64                 sorted1 = true;
 65                 //Here I loop through the selected Students being focused on
 66                 for (int i = 0; i < n1; i++) {
 67                     //Below I establish the best trials for the 2 students that I am comparing
 68                     double LowerBest = bestTrial.bestTrialDistance(blockToSearchList.get(i).getShotPut1(), blockToSearchList.get(i).getShotPut2(), blockToSearchList.get(i).getShotPut3());
 69                     double HigherBest = bestTrial.bestTrialDistance(blockToSearchList.get(i + 1).getShotPut1(), blockToSearchList.get(i + 1).getShotPut2(), blockToSearchList.get(i + 1).getShotPut3());
 70                     //if the 'lower' Student's score is better than the 'higher' student's score then a switch is carried out
 71                     if (LowerBest > HigherBest) {
 72                         //refer to SortAndSearch.java, lines 32-39 for description of the switch
 73                         Student temp = blockToSearchList.get(i); 
 74                         blockToSearchList.set(i, blockToSearchList.get(i + 1)); 
 75                         blockToSearchList.set(i + 1, temp);
 76                         sorted1 = false;
 77 
 78                     }
 79                 }
 80                 String[] bestStudentsArray = new String[6];
 81                 for(int b = 0; b < bestStudentsArray.length-1; b++){
 82                     bestStudentsArray[b] = new String();
 83                 }
 84                 int countDown = blockToSearchList.size() - 1;
 85                 for (int a = 0; a < 6; a += 2) {
 86                     bestStudentsArray[a] = blockToSearchList.get(countDown).getStudentName();
 87                     bestStudentsArray[a + 1] = Double.toString(bestTrial.bestTrialDistance(blockToSearchList.get(countDown).getShotPut1(), blockToSearchList.get(countDown).getShotPut2(), blockToSearchList.get(countDown).getShotPut3()));
 88 
 89                     countDown--;
 90                 }
 91 
 92                 return bestStudentsArray;
 93             }
 94 
 95             //For all the other categories the code is the same, with just a different category
 96             //refer to lines 61 - 93 for description
 97         } else if (category.equals("Javelin")) {
 98             while (!sorted1) {
 99                 n1--;
100                 sorted1 = true;
101                 for (int i = 0; i < n1; i++) {
102                     double LowerBest = bestTrial.bestTrialDistance(blockToSearchList.get(i).getJavelin1(), blockToSearchList.get(i).getJavelin2(), blockToSearchList.get(i).getJavelin3());
103                     double HigherBest = bestTrial.bestTrialDistance(blockToSearchList.get(i + 1).getJavelin1(), blockToSearchList.get(i + 1).getJavelin2(), blockToSearchList.get(i + 1).getJavelin3());
104                     if (LowerBest > HigherBest) {
105                         Student temp = blockToSearchList.get(i); //making a temporary carList object
106                         blockToSearchList.set(i, blockToSearchList.get(i + 1)); //set first to be the second
107                         blockToSearchList.set(i + 1, temp);//set the second to be the temp
108                         sorted1 = false;
109 
110                     }
111                 }
112                 String[] bestStudentsArray = new String[6];
113                 for(int b = 0; b < bestStudentsArray.length-1; b++){
114                     bestStudentsArray[b] = new String();
115                 }
116                 int countDown = blockToSearchList.size() - 1;
117                 for (int a = 0; a < 6; a += 2) {
118                     bestStudentsArray[a] = blockToSearchList.get(countDown).getStudentName();
119                     bestStudentsArray[a + 1] = Double.toString(bestTrial.bestTrialDistance(blockToSearchList.get(countDown).getJavelin1(), blockToSearchList.get(countDown).getJavelin2(), blockToSearchList.get(countDown).getJavelin3()));
120 
121                     countDown--;
122                 }
123 
124                 return bestStudentsArray;
125             }
126 
127         } else if (category.equals("Discuss")) {
128             while (!sorted1) {
129                 n1--;
130                 sorted1 = true;
131                 for (int i = 0; i < n1; i++) {
132                     double LowerBest = bestTrial.bestTrialDistance(blockToSearchList.get(i).getDiscuss1(), blockToSearchList.get(i).getDiscuss2(), blockToSearchList.get(i).getDiscuss3());
133                     double HigherBest = bestTrial.bestTrialDistance(blockToSearchList.get(i + 1).getDiscuss1(), blockToSearchList.get(i + 1).getDiscuss2(), blockToSearchList.get(i + 1).getDiscuss3());
134                     if (LowerBest > HigherBest) {
135                         Student temp = blockToSearchList.get(i); 
136                         blockToSearchList.set(i, blockToSearchList.get(i + 1)); 
137                         blockToSearchList.set(i + 1, temp);
138                         sorted1 = false;
139 
140                     }
141                 }
142                 String[] bestStudentsArray = new String[6];
143                 for(int b = 0; b < bestStudentsArray.length-1; b++){
144                     bestStudentsArray[b] = new String();
145                 }
146                 
147                 int countDown = blockToSearchList.size() - 1;
148                 for (int a = 0; a < 6; a += 2) {
149                     bestStudentsArray[a] = blockToSearchList.get(countDown).getStudentName();
150                     bestStudentsArray[a + 1] = Double.toString(bestTrial.bestTrialDistance(blockToSearchList.get(countDown).getDiscuss1(), blockToSearchList.get(countDown).getDiscuss2(), blockToSearchList.get(countDown).getDiscuss3()));
151 
152                     countDown--;
153                 }
154 
155                 return bestStudentsArray;
156             }
157 
158         } else if (category.equals("Long Jump")) {
159             while (!sorted1) {
160                 n1--;
161                 sorted1 = true;
162                 for (int i = 0; i < n1; i++) {
163                     double LowerBest =  bestTrial.bestTrialDistance(blockToSearchList.get(i).getLongJump1(), blockToSearchList.get(i).getLongJump2(), blockToSearchList.get(i).getLongJump3());
164                     double HigherBest = bestTrial.bestTrialDistance(blockToSearchList.get(i+1).getLongJump1(), blockToSearchList.get(i+1).getLongJump2(), blockToSearchList.get(i+1).getLongJump3());
165                     if(LowerBest > HigherBest){
166                         Student temp = blockToSearchList.get(i); 
167                         blockToSearchList.set(i, blockToSearchList.get(i + 1)); 
168                         blockToSearchList.set(i + 1, temp);
169                         sorted1 = false;
170 
171                     }
172                 }
173                 String [] bestStudentsArray = new String [6];
174                 for(int b = 0; b < bestStudentsArray.length-1; b++){
175                     bestStudentsArray[b] = new String();
176                 }
177                 int countDown = blockToSearchList.size() -1;
178                 for(int a = 0; a < 6; a+= 2){
179                     bestStudentsArray[a] = blockToSearchList.get(countDown).getStudentName();
180                     bestStudentsArray[a+1] = Double.toString(bestTrial.bestTrialDistance(blockToSearchList.get(countDown).getLongJump1(), blockToSearchList.get(countDown).getLongJump2(), blockToSearchList.get(countDown).getLongJump3()));
181                     
182                     countDown --;
183                 }
184                 
185                 return bestStudentsArray;
186         }
187 
188         } else if (category.equals("60 meter run")) {
189             while (!sorted1) {
190                 n1--;
191                 sorted1 = true;
192                 for (int i = 0; i < n1; i++) {
193                     double LowerBest =  bestTrial.bestTrialTimeSeconds(blockToSearchList.get(i).getSixtyMeter1().get(Calendar.SECOND), blockToSearchList.get(i).getSixtyMeter2().get(Calendar.SECOND));
194                     double HigherBest = bestTrial.bestTrialTimeSeconds(blockToSearchList.get(i+1).getSixtyMeter1().get(Calendar.SECOND), blockToSearchList.get(i+1).getSixtyMeter2().get(Calendar.SECOND));
195                     if(LowerBest < HigherBest){
196                         Student temp = blockToSearchList.get(i); 
197                         blockToSearchList.set(i, blockToSearchList.get(i + 1)); 
198                         blockToSearchList.set(i + 1, temp);
199                         sorted1 = false;
200 
201                     }
202                 }
203                 String [] bestStudentsArray = new String [6];
204                 for(int b = 0; b < bestStudentsArray.length-1; b++){
205                     bestStudentsArray[b] = new String();
206                 }
207                 int countDown = blockToSearchList.size() -1;
208                 for(int a = 0; a < 6; a+= 2){
209                     bestStudentsArray[a] = blockToSearchList.get(countDown).getStudentName();
210                     bestStudentsArray[a+1] = Double.toString(bestTrial.bestTrialTimeSeconds(blockToSearchList.get(countDown).getSixtyMeter1().get(Calendar.SECOND), blockToSearchList.get(countDown).getSixtyMeter2().get(Calendar.SECOND)));
211                     
212                     countDown --;
213                 }
214                 
215                 return bestStudentsArray;
216             }
217 
218         } else if (category.equals("200 meter run")) {
219             while (!sorted1) {
220                 n1--;
221                 sorted1 = true;
222                 for (int i = 0; i < n1; i++) {
223                     double LowerBest =  bestTrial.bestTrialTimeSeconds(blockToSearchList.get(i).getTwoHundredMeter1().get(Calendar.SECOND), blockToSearchList.get(i).getTwoHundredMeter2().get(Calendar.SECOND));
224                     double HigherBest = bestTrial.bestTrialTimeSeconds(blockToSearchList.get(i+1).getTwoHundredMeter1().get(Calendar.SECOND), blockToSearchList.get(i+1).getTwoHundredMeter2().get(Calendar.SECOND));
225                     if(LowerBest < HigherBest){
226                         Student temp = blockToSearchList.get(i); //making a temporary carList object
227                         blockToSearchList.set(i, blockToSearchList.get(i + 1)); //set first to be the second
228                         blockToSearchList.set(i + 1, temp);//set the second to be the temp
229                         sorted1 = false;
230 
231                     }
232                 }
233                 String [] bestStudentsArray = new String [6];
234                 for(int b = 0; b < bestStudentsArray.length-1; b++){
235                     bestStudentsArray[b] = new String();
236                 }
237                 int countDown = blockToSearchList.size() -1;
238                 for(int a = 0; a < 6; a+= 2){
239                     bestStudentsArray[a] = blockToSearchList.get(countDown).getStudentName();
240                     bestStudentsArray[a+1] = Double.toString(bestTrial.bestTrialTimeSeconds(blockToSearchList.get(countDown).getSixtyMeter1().get(Calendar.SECOND), blockToSearchList.get(countDown).getSixtyMeter2().get(Calendar.SECOND)));
241                     
242                     countDown --;
243                 }
244                 
245                 return bestStudentsArray;
246             }
247         } else if (category.equals("1,500 meter run")) {
248             while (!sorted1) {
249                 n1--;
250                 sorted1 = true;
251                 for (int i = 0; i < n1; i++) {
252                     
253                     //Here, firstly the total seconds of both trials, for both students have to be calculated
254                     int lowerTotalSec1 = (blockToSearchList.get(i).getOneK500Meter1().get(Calendar.SECOND) + (blockToSearchList.get(i).getOneK500Meter1().get(Calendar.MINUTE)*60));
255                     int lowerTotalSec2 = (blockToSearchList.get(i).getOneK500Meter2().get(Calendar.SECOND) + (blockToSearchList.get(i).getOneK500Meter2().get(Calendar.MINUTE)*60));
256                     
257                     int higherTotalSec1 = (blockToSearchList.get(i+1).getOneK500Meter1().get(Calendar.SECOND) + (blockToSearchList.get(i+1).getOneK500Meter1().get(Calendar.MINUTE)*60));
258                     int higherTotalSec2 = (blockToSearchList.get(i+1).getOneK500Meter1().get(Calendar.SECOND) + (blockToSearchList.get(i+1).getOneK500Meter1().get(Calendar.MINUTE)*60));
259                     
260                     //Then the best Trial is found, comparing the calculated values
261                     double LowerBestTotalSec =  bestTrial.bestTrialTimeSeconds(lowerTotalSec1, lowerTotalSec2);
262                     double HigherBestTotalSec = bestTrial.bestTrialTimeSeconds(higherTotalSec1, higherTotalSec2);
263                     if(LowerBestTotalSec < HigherBestTotalSec){
264                         Student temp = blockToSearchList.get(i); //making a temporary carList object
265                         blockToSearchList.set(i, blockToSearchList.get(i + 1)); //set first to be the second
266                         blockToSearchList.set(i + 1, temp);//set the second to be the temp
267                         sorted1 = false;
268 
269                     }
270                 }
271                 String [] bestStudentsArray = new String [6];
272                 for(int b = 0; b < bestStudentsArray.length-1; b++){
273                     bestStudentsArray[b] = new String();
274                 }
275                 int countDown = blockToSearchList.size() -1;
276                 for(int a = 0; a < 6; a+= 2){
277                     bestStudentsArray[a] = blockToSearchList.get(countDown).getStudentName();
278                     int totalSec1 = (blockToSearchList.get(countDown).getOneK500Meter1().get(Calendar.SECOND) + (blockToSearchList.get(countDown).getOneK500Meter1().get(Calendar.MINUTE)*60));
279                     int totalSec2 = (blockToSearchList.get(countDown).getOneK500Meter2().get(Calendar.SECOND) + (blockToSearchList.get(countDown).getOneK500Meter2().get(Calendar.MINUTE)*60));
280                     
281                     int bestTrialSec = (int) bestTrial.bestTrialTimeSeconds(totalSec1, totalSec2);
282                     bestStudentsArray[a+1] = Integer.toString(bestTrialSec);
283                     
284                     countDown --;
285                 }
286                 
287                 return bestStudentsArray;
288         
289 
290     }
291         }
292         //If there is an error, and empty Array is created and returned
293         String [] bestStudentsArray = new String [6];
294         return bestStudentsArray;
295     }
296 
297     //All the code here is done the same, only the search criteria is the year and not the class
298     //Therefore refer to lines 17-96 for description
299     public String [] yearBestScore(ArrayList<Student> studentList, String yearToSearch, String category) {
300         
301         int n = studentList.size();
302         boolean sorted = false;
303         while (!sorted) {
304             n--;
305             sorted = true;
306             for (int i = 0; i < n; i++) {
307                 if (studentList.get(i).getStudentYear().compareTo(studentList.get(i + 1).getStudentYear()) > 0) {
308                     Student temp = studentList.get(i); //making a temporary carList object
309                     studentList.set(i, studentList.get(i + 1)); //set first to be the second
310                     studentList.set(i + 1, temp);//set the second to be the temp
311                     sorted = false;
312 
313                 }
314             }
315         }
316         //find the chosen class
317         ArrayList<Student> yearToSearchList = new ArrayList();
318 
319         int counter = 0;
320         for (int i = 0; i < studentList.size(); i++) {
321             if (studentList.get(i).getStudentYear().equals(yearToSearch)) {
322                 yearToSearchList.add(studentList.get(i));
323             }
324         }
325         //sort new array and take last student's score (top score)
326 
327         BestTrial bestTrial = new BestTrial();
328         double bestScoreIndex = -1;
329         int n1 = yearToSearchList.size();
330         boolean sorted1 = false;
331 
332         if (category.equals("Shotput")) {
333 
334             while (!sorted1) {
335                 n1--;
336                 sorted1 = true;
337                 for (int i = 0; i < n1; i++) {
338                     double LowerBest = bestTrial.bestTrialDistance(yearToSearchList.get(i).getShotPut1(), yearToSearchList.get(i).getShotPut2(), yearToSearchList.get(i).getShotPut3());
339                     double HigherBest = bestTrial.bestTrialDistance(yearToSearchList.get(i + 1).getShotPut1(), yearToSearchList.get(i + 1).getShotPut2(), yearToSearchList.get(i + 1).getShotPut3());
340                     if (LowerBest > HigherBest) {
341                         Student temp = yearToSearchList.get(i); //making a temporary carList object
342                         yearToSearchList.set(i, yearToSearchList.get(i + 1)); //set first to be the second
343                         yearToSearchList.set(i + 1, temp);//set the second to be the temp
344                         sorted1 = false;
345 
346                     }
347                 }
348                 String[] bestStudentsArray = new String[6];
349                 for(int b = 0; b < bestStudentsArray.length-1; b++){
350                     bestStudentsArray[b] = new String();
351                 }
352                 int countDown = yearToSearchList.size() - 1;
353                 for (int a = 0; a < 6; a += 2) {
354                     bestStudentsArray[a] = yearToSearchList.get(countDown).getStudentName();
355                     bestStudentsArray[a + 1] = Double.toString(bestTrial.bestTrialDistance(yearToSearchList.get(countDown).getShotPut1(), yearToSearchList.get(countDown).getShotPut2(), yearToSearchList.get(countDown).getShotPut3()));
356 
357                     countDown--;
358                 }
359 
360                 return bestStudentsArray;
361             }
362 
363         } else if (category.equals("Javelin")) {
364             while (!sorted1) {
365                 n1--;
366                 sorted1 = true;
367                 for (int i = 0; i < n1; i++) {
368                     double LowerBest = bestTrial.bestTrialDistance(yearToSearchList.get(i).getJavelin1(), yearToSearchList.get(i).getJavelin2(), yearToSearchList.get(i).getJavelin3());
369                     double HigherBest = bestTrial.bestTrialDistance(yearToSearchList.get(i + 1).getJavelin1(), yearToSearchList.get(i + 1).getJavelin2(), yearToSearchList.get(i + 1).getJavelin3());
370                     if (LowerBest > HigherBest) {
371                         Student temp = yearToSearchList.get(i); //making a temporary carList object
372                         yearToSearchList.set(i, yearToSearchList.get(i + 1)); //set first to be the second
373                         yearToSearchList.set(i + 1, temp);//set the second to be the temp
374                         sorted1 = false;
375 
376                     }
377                 }
378                 String[] bestStudentsArray = new String[6];
379                 for(int b = 0; b < bestStudentsArray.length-1; b++){
380                     bestStudentsArray[b] = new String();
381                 }
382                 int countDown = yearToSearchList.size() - 1;
383                 for (int a = 0; a < 6; a += 2) {
384                     bestStudentsArray[a] = yearToSearchList.get(countDown).getStudentName();
385                     bestStudentsArray[a + 1] = Double.toString(bestTrial.bestTrialDistance(yearToSearchList.get(countDown).getJavelin1(), yearToSearchList.get(countDown).getJavelin2(), yearToSearchList.get(countDown).getJavelin3()));
386 
387                     countDown--;
388                 }
389 
390                 return bestStudentsArray;
391             }
392 
393         } else if (category.equals("Discuss")) {
394             while (!sorted1) {
395                 n1--;
396                 sorted1 = true;
397                 for (int i = 0; i < n1; i++) {
398                     double LowerBest = bestTrial.bestTrialDistance(yearToSearchList.get(i).getDiscuss1(), yearToSearchList.get(i).getDiscuss2(), yearToSearchList.get(i).getDiscuss3());
399                     double HigherBest = bestTrial.bestTrialDistance(yearToSearchList.get(i + 1).getDiscuss1(), yearToSearchList.get(i + 1).getDiscuss2(), yearToSearchList.get(i + 1).getDiscuss3());
400                     if (LowerBest > HigherBest) {
401                         Student temp = yearToSearchList.get(i); //making a temporary carList object
402                         yearToSearchList.set(i, yearToSearchList.get(i + 1)); //set first to be the second
403                         yearToSearchList.set(i + 1, temp);//set the second to be the temp
404                         sorted1 = false;
405 
406                     }
407                 }
408                 String[] bestStudentsArray = new String[6];
409                 for(int b = 0; b < bestStudentsArray.length-1; b++){
410                     bestStudentsArray[b] = new String();
411                 }
412                 int countDown = yearToSearchList.size() - 1;
413                 for (int a = 0; a < 6; a += 2) {
414                     bestStudentsArray[a] = yearToSearchList.get(countDown).getStudentName();
415                     bestStudentsArray[a + 1] = Double.toString(bestTrial.bestTrialDistance(yearToSearchList.get(countDown).getDiscuss1(), yearToSearchList.get(countDown).getDiscuss2(), yearToSearchList.get(countDown).getDiscuss3()));
416 
417                     countDown--;
418                 }
419 
420                 return bestStudentsArray;
421             }
422 
423         } else if (category.equals("Long Jump")) {
424             while (!sorted1) {
425                 n1--;
426                 sorted1 = true;
427                 for (int i = 0; i < n1; i++) {
428                     double LowerBest =  bestTrial.bestTrialDistance(yearToSearchList.get(i).getLongJump1(), yearToSearchList.get(i).getLongJump2(), yearToSearchList.get(i).getLongJump3());
429                     double HigherBest = bestTrial.bestTrialDistance(yearToSearchList.get(i+1).getLongJump1(), yearToSearchList.get(i+1).getLongJump2(), yearToSearchList.get(i+1).getLongJump3());
430                     if(LowerBest > HigherBest){
431                         Student temp = yearToSearchList.get(i); //making a temporary carList object
432                         yearToSearchList.set(i, yearToSearchList.get(i + 1)); //set first to be the second
433                         yearToSearchList.set(i + 1, temp);//set the second to be the temp
434                         sorted1 = false;
435 
436                     }
437                 }
438                 String [] bestStudentsArray = new String [6];
439                 for(int b = 0; b < bestStudentsArray.length-1; b++){
440                     bestStudentsArray[b] = new String();
441                 }
442                 int countDown = yearToSearchList.size() -1;
443                 for(int a = 0; a < 6; a+= 2){
444                     bestStudentsArray[a] = yearToSearchList.get(countDown).getStudentName();
445                     bestStudentsArray[a+1] = Double.toString(bestTrial.bestTrialDistance(yearToSearchList.get(countDown).getLongJump1(), yearToSearchList.get(countDown).getLongJump2(), yearToSearchList.get(countDown).getLongJump3()));
446                     
447                     countDown --;
448                 }
449                 
450                 return bestStudentsArray;
451         }
452 
453         } else if (category.equals("60 meter run")) {
454             while (!sorted1) {
455                 n1--;
456                 sorted1 = true;
457                 for (int i = 0; i < n1; i++) {
458                     double LowerBest =  bestTrial.bestTrialTimeSeconds(yearToSearchList.get(i).getSixtyMeter1().get(Calendar.SECOND), yearToSearchList.get(i).getSixtyMeter2().get(Calendar.SECOND));
459                     double HigherBest = bestTrial.bestTrialTimeSeconds(yearToSearchList.get(i+1).getSixtyMeter1().get(Calendar.SECOND), yearToSearchList.get(i+1).getSixtyMeter2().get(Calendar.SECOND));
460                     if(LowerBest < HigherBest){
461                         Student temp = yearToSearchList.get(i); //making a temporary carList object
462                         yearToSearchList.set(i, yearToSearchList.get(i + 1)); //set first to be the second
463                         yearToSearchList.set(i + 1, temp);//set the second to be the temp
464                         sorted1 = false;
465 
466                     }
467                 }
468                 String [] bestStudentsArray = new String [6];
469                 for(int b = 0; b < bestStudentsArray.length-1; b++){
470                     bestStudentsArray[b] = new String();
471                 }
472                 int countDown = yearToSearchList.size() -1;
473                 for(int a = 0; a < 6; a+= 2){
474                     bestStudentsArray[a] = yearToSearchList.get(countDown).getStudentName();
475                     bestStudentsArray[a+1] = Double.toString(bestTrial.bestTrialTimeSeconds(yearToSearchList.get(countDown).getSixtyMeter1().get(Calendar.SECOND), yearToSearchList.get(countDown).getSixtyMeter2().get(Calendar.SECOND)));
476                     
477                     countDown --;
478                 }
479                 
480                 return bestStudentsArray;
481             }
482 
483         } else if (category.equals("200 meter run")) {
484             while (!sorted1) {
485                 n1--;
486                 sorted1 = true;
487                 for (int i = 0; i < n1; i++) {
488                     double LowerBest =  bestTrial.bestTrialTimeSeconds(yearToSearchList.get(i).getTwoHundredMeter1().get(Calendar.SECOND), yearToSearchList.get(i).getTwoHundredMeter2().get(Calendar.SECOND));
489                     double HigherBest = bestTrial.bestTrialTimeSeconds(yearToSearchList.get(i+1).getTwoHundredMeter1().get(Calendar.SECOND), yearToSearchList.get(i+1).getTwoHundredMeter2().get(Calendar.SECOND));
490                     if(LowerBest < HigherBest){
491                         Student temp = yearToSearchList.get(i); //making a temporary carList object
492                         yearToSearchList.set(i, yearToSearchList.get(i + 1)); //set first to be the second
493                         yearToSearchList.set(i + 1, temp);//set the second to be the temp
494                         sorted1 = false;
495 
496                     }
497                 }
498                 String [] bestStudentsArray = new String [6];
499                 for(int b = 0; b < bestStudentsArray.length-1; b++){
500                     bestStudentsArray[b] = new String();
501                 }
502                 int countDown = yearToSearchList.size() -1;
503                 for(int a = 0; a < 6; a+= 2){
504                     bestStudentsArray[a] = yearToSearchList.get(countDown).getStudentName();
505                     bestStudentsArray[a+1] = Double.toString(bestTrial.bestTrialTimeSeconds(yearToSearchList.get(countDown).getSixtyMeter1().get(Calendar.SECOND), yearToSearchList.get(countDown).getSixtyMeter2().get(Calendar.SECOND)));
506                     
507                     countDown --;
508                 }
509                 
510                 return bestStudentsArray;
511             }
512         } else if (category.equals("1,500 meter run")) {
513             while (!sorted1) {
514                 n1--;
515                 sorted1 = true;
516                 for (int i = 0; i < n1; i++) {
517                     int lowerTotalSec1 = (yearToSearchList.get(i).getOneK500Meter1().get(Calendar.SECOND) + (yearToSearchList.get(i).getOneK500Meter1().get(Calendar.MINUTE)*60));
518                     int lowerTotalSec2 = (yearToSearchList.get(i).getOneK500Meter2().get(Calendar.SECOND) + (yearToSearchList.get(i).getOneK500Meter2().get(Calendar.MINUTE)*60));
519                     
520                     int higherTotalSec1 = (yearToSearchList.get(i+1).getOneK500Meter1().get(Calendar.SECOND) + (yearToSearchList.get(i+1).getOneK500Meter1().get(Calendar.MINUTE)*60));
521                     int higherTotalSec2 = (yearToSearchList.get(i+1).getOneK500Meter1().get(Calendar.SECOND) + (yearToSearchList.get(i+1).getOneK500Meter1().get(Calendar.MINUTE)*60));
522                     
523                     double LowerBestTotalSec =  bestTrial.bestTrialTimeSeconds(lowerTotalSec1, lowerTotalSec2);
524                     double HigherBestTotalSec = bestTrial.bestTrialTimeSeconds(higherTotalSec1, higherTotalSec2);
525                     if(LowerBestTotalSec < HigherBestTotalSec){
526                         Student temp = yearToSearchList.get(i); //making a temporary carList object
527                         yearToSearchList.set(i, yearToSearchList.get(i + 1)); //set first to be the second
528                         yearToSearchList.set(i + 1, temp);//set the second to be the temp
529                         sorted1 = false;
530 
531                     }
532                 }
533                 String [] bestStudentsArray = new String [6];
534                 for(int b = 0; b < bestStudentsArray.length-1; b++){
535                     bestStudentsArray[b] = new String();
536                 }
537                 int countDown = yearToSearchList.size() -1;
538                 for(int a = 0; a < 6; a+= 2){
539                     bestStudentsArray[a] = yearToSearchList.get(countDown).getStudentName();
540                     int totalSec1 = (yearToSearchList.get(countDown).getOneK500Meter1().get(Calendar.SECOND) + (yearToSearchList.get(countDown).getOneK500Meter1().get(Calendar.MINUTE)*60));
541                     int totalSec2 = (yearToSearchList.get(countDown).getOneK500Meter2().get(Calendar.SECOND) + (yearToSearchList.get(countDown).getOneK500Meter2().get(Calendar.MINUTE)*60));
542                     
543                     
544                     int bestTrialSec = (int) bestTrial.bestTrialTimeSeconds(totalSec1, totalSec2);
545                     bestStudentsArray[a+1] = Integer.toString(bestTrialSec);
546                     
547                     countDown --;
548                 }
549                 
550                 return bestStudentsArray;
551         
552 
553     }
554         }
555         
556        String [] bestStudentsArray = new String [6];
557         return bestStudentsArray;
558     }
559 }
560