public class Project3 {
public static void main(String[] args) {
Input3 input = new Input3();
Team teams[] = new Team[input.NUMBER_OF_TEAMS];
Player players[] = new Player[input.NUMBER_OF_PLAYERS];
String playas[] = new String[input.NUMBER_OF_PLAYERS];
String temp;
for ( int i=0 ; i<3 ; i++ ) {
String name = input.getNextString();
for ( int j=0 ; j<5 ; j++ )
playas[j] = input.getNextString();
teams[i] = new Team(name, playas);
teams[i].sortPlayers();
System.out.println(teams[i]);
}
}
}
////////////////////////////
public class Player {
public String[] name;
public Player(String inputname) {
name = inputname.split(" ");
}
public String[] getName() {
return name;
}
public String getFirstName() {
return name[0];
}
public String getLastName() {
String last = name[1];
return "Baker";
}
}
///////////////////////////
public class Team {
private String name;
public Player players[];
public Player temp;
public Team(String inputname, String playas[]) {
inputname = name;
players = new Player [playas.length];
for( int k=0 ; k<playas.length ; k++ )
this.players[k] = new Player(playas[k]);
}
public void sortPlayers() {
int n = players.length;
for (int pass=1; pass < n; pass++){
for (int i=0; i < n-pass; i++) {
String playerName = players[i].getLastName();
String nextPlayerName = players[i+1].getLastName();
if(playerName.compareTo(nextPlayerName) > 0)
temp = players[i];
players[i] = players[i+1];
players[i+1] = temp;
}
}
}
}
//Input3 class goes here. Assume it works, and returns strings in the form of "Firstname Lastname"