private static TeamInfo randomTeam(ArrayList<TeamInfo> list) {
    int index = random.nextInt(list.size());
    TeamInfo team = list.get(index);
    // If the selected team is expired, remove it and return a new team.
    long currTime = System.currentTimeMillis();
    if ((team.getEndTimeInMillis() < currTime) || team.numMembers() == 0) {
      System.out.println("\nteam " + team + " is too old; replacing.");
      System.out.println("start time: " + team.getStartTimeInMillis()
        + ", end time: " + team.getEndTimeInMillis()
        + ", current time:" + currTime);
      removeTeam(index);
      // Add a new team in its stead.
      return (addLiveTeam());
    } else {
      return team;
    }
  }
private static TeamInfo randomTeam ( ArrayList < TeamInfo > list ) { int index = random . nextInt ( list . size ( ) ) ; TeamInfo team = list . get ( index ) ; long currTime = System . currentTimeMillis ( ) ; if ( ( team . getEndTimeInMillis ( ) < currTime ) || team . numMembers ( ) == 0 ) { System . out . println ( "\nteam " + team + " is too old; replacing." ) ; System . out . println ( "start time: " + team . getStartTimeInMillis ( ) + ", end time: " + team . getEndTimeInMillis ( ) + ", current time:" + currTime ) ; removeTeam ( index ) ; return ( addLiveTeam ( ) ) ; } else { return team ; } }
Get and return a random team. If the selected team is too old w.r.t its expiration, remove
it, replacing it with a new team.