Package ise.mace.groups.freeagentgroups

Source Code of ise.mace.groups.freeagentgroups.BasicFreeAgentGroup

package ise.mace.groups.freeagentgroups;

import ise.mace.models.HuntingTeam;
import ise.mace.participants.AbstractFreeAgentGroup;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Random;

/**
*
*/
public class BasicFreeAgentGroup extends AbstractFreeAgentGroup
{
  private Comparator<String> c = new Comparator<String>() {
      private Random r = new Random(0);
      @Override
      public int compare(String o1, String o2)
      {
        return (r.nextBoolean() ? -1 : 1);
      }
    };

  @Override
  public List<HuntingTeam> selectTeams(List<String> freeAgents)
  {
    ArrayList<HuntingTeam> teams = new ArrayList<HuntingTeam>();
    List<String> agents = new ArrayList<String>(freeAgents);
    Collections.sort(agents, c);

    int count = agents.size();
               
                for(int i=0; i < count; i += 2){
      int ubound = (i + 2 >= count) ? count : i + 2;
      teams.add(new HuntingTeam (agents.subList(i, ubound)));
    }

    return teams;
  }
 
}
TOP

Related Classes of ise.mace.groups.freeagentgroups.BasicFreeAgentGroup

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.