コード例 #1
0
  @Override
  public synchronized int onEventExternalRequest(
      ArrayList<ElevatorController> elevators, Request extRequest) {
    // count total number of elevator requests
    int sum = 0;
    for (ElevatorController e : elevators) sum += e.getExternal().size();

    if (sum < 10) return stoch.onEventExternalRequest(elevators, extRequest);
    else if (sum < 30) return closest.onEventExternalRequest(elevators, extRequest);

    return queue.onEventExternalRequest(elevators, extRequest);
  }
コード例 #2
0
 @Override
 public int onEventInternalRequest(ElevatorController ECL, ArrayList<Integer> internalRequests) {
   boolean exists = false;
   for (Integer intRequest : internalRequests) {
     int request = intRequest.intValue();
     exists = false;
     for (Integer eleQueue : ECL.getQueue()) {
       if (eleQueue.intValue() == request) {
         exists = true;
         break;
       }
     }
     if (exists) continue;
     else ECL.getQueue().add(request);
   }
   return 0;
 }