Code:
private List<Team> mTeamList = new ArrayList<Team>();
private final static int sNUM_DIVISIONS = 4;
private static Timer t = new Timer("Randomizer");
private static TimerTask divTask = new TimerTask(){
Integer division = -1;
@Override
public void run(){
synchronized(division){
division = (int)(new Random(System.nanoTime()).nextDouble() * sNUM_DIVISIONS);
//Indexes the divisions from 0 to 3, which would match the ordinals of division enums
}
}
public int getDivision(){
synchronized(division){
return division;
}
}
}
static{
initTeamList(); // Populates the team list with teams who are attending Atlanta
t.schedule(divTask, 0, Math.random()*1000);
Iterator<Team> it = mTeamList.iterator();
Timer teamDivTimer = new Timer("Division Assignment");
TimerTask teamTT = new TimerTask(){
public void run(){
if(it.hasNext())
it.next().setDivision(divTask.getDivision();
else
cancel();
}
}
teamDivTimer.schedule(teamTT, 0, Math.random()*1000);
}
Run it, the select random teams to even out the number of teams in each division. 'nuff said