import java.util.ArrayList;
import java.util.Collections;
import java.lang.Object;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Bracket_Creator{
public static void main(String[] args) throws FileNotFoundException
{
String first_name = "";
String last_name = "";
String school = "";
int weight = 0;
int confer_win = 0;
int confer_loss = 0;
int overall_wins = 0;
int overall_loss = 0;
ArrayList<Wrestler> list = new ArrayList<Wrestler>();
int i = 0;
boolean flag = true;
//new scanner instance
Scanner scanner = new Scanner(new File("wrestlers.csv"));
//the seperator for the file
scanner.useDelimiter(",");
while(scanner.hasNext()){
first_name = scanner.next();
last_name = scanner.next();
school = scanner.next();
weight = scanner.nextInt();
confer_win = scanner.nextInt();
confer_loss = scanner.nextInt();
overall_wins = scanner.nextInt();
overall_loss = scanner.nextInt();
list.add(new Wrestler(first_name,last_name,school,weight,
confer_win,confer_loss,overall_wins,overall_loss));
System.out.println((list.get(i).get_first_name()));
i++;
}//end while
scanner.close();
//make the percentages for the wrestlers
for (i = 0; i < list.size(); i++){
(list.get(i)).determine_conf_percentage((list.get(i)).get_confer_wins(), (list.get(i)).get_confer_losses());
(list.get(i)).determine_overall_percentage((list.get(i)).get_overall_wins(), (list.get(i)).get_overall_losses());
}//end for loop
//set rank
while ( flag )
{
flag= false; //set flag to false awaiting a possible swap
for( i=0; i < list.size() -1; i++ )
{
if ((list.get(i)).get_confer_percentage() < (list.get(i+1)).get_confer_percentage() )
{
Collections.swap(list, i, i+1);
flag = true;
}//end if
}//end for
}//end while
//set rank value
for (i = 0; i< list.size(); i++){
(list.get(i)).set_rank(i + 1);
}//end for loop
for (i = 0; i< list.size(); i++){
System.out.println((list.get(i)).get_first_name());
}
System.out.println("");
/*
*
*
*Create the Bracket!
*
*
*/
int j = 1; //J here is for the end of the list, every time you go through
//add one to J in the loop to keep on coming in from the other end of
//the list
for (i = 0; i< (list.size()/2); i++){
if (i == 0) {//first pass thru the list
System.out.println((list.get(i)).get_first_name());
System.out.println((list.get(list.size()-j)).get_first_name());
System.out.println();
j++;
}//end if
else{
System.out.println((list.get(i)).get_first_name());
System.out.println((list.get(list.size()-j)).get_first_name());
System.out.println();
j++;
}//end else
}//end for
}//end main
}//end bracket_creator class