Exemplo n.º 1
0
 public static AgentData createUniqueRandomAgentData(
     List<AgentData> alreadyAddedAgents,
     Coordinates leftTopCoordinates,
     Coordinates rightDownCoordinates) {
   AgentData randomAgent = new AgentData();
   int counter = 0;
   while (true) {
     fillRandomAgentPosition(randomAgent, leftTopCoordinates, rightDownCoordinates);
     if (!AgentListenersHelper.agentAlreadyCreated(randomAgent, alreadyAddedAgents)) {
       return randomAgent;
     }
     counter++;
     if (counter > 200) {
       throw new IllegalArgumentException("to less space for agents");
     }
   }
 }
Exemplo n.º 2
0
 public static JTextField createUniqueRandomAgent(
     List<JTextField> alreadyAddedAgents,
     Coordinates leftTopCoordinates,
     Coordinates rightDownCoordinates) {
   int counter = 0;
   while (true) {
     JTextField randomAgent =
         generateRandomAgentPosition(leftTopCoordinates, rightDownCoordinates);
     if (!AgentListenersHelper.agentAlreadyCreated(randomAgent, alreadyAddedAgents)) {
       return randomAgent;
     }
     counter++;
     if (counter > 200) {
       throw new IllegalArgumentException("to less space for agents");
     }
   }
 }