public CarController(Car c, float stoppingDist) {
    super();
    search = null;
    car = c;
    stoppingDistance = stoppingDist;
    assignments = new CarAssignments(car.getName());

    floors = Building.getFloorList();

    car.getFloorRequestPanel()
        .addListener(
            new FloorRequestPanel.Listener() {
              public void floorRequested(Floor destinationFloor) {
                List<CarController> carControllers = new ArrayList<CarController>();
                HashSet<Assignment> tempAssignments = new HashSet<Assignment>();
                carControllers.add((CarController) getCarController());
                // System.out.println(carControllers);
                for (Iterator i = assignments.iterator(); i.hasNext(); ) {
                  tempAssignments.add((Assignment) i.next());
                }
                tempAssignments.add(new Assignment(destinationFloor, Direction.NONE));

                CarControllerList carControllerList =
                    AStar.AStarSearch(tempAssignments, carControllers);
                carControllers = carControllerList.getList();
                for (Iterator i = carControllers.iterator(); i.hasNext(); ) {
                  CarController controller = (CarController) i.next();
                  controller.setNextDestination();
                  //  for(Iterator j=controller.getCarAssignments().iterator();j.hasNext();){
                  //	  Assignment ass=(Assignment) j.next();
                  //	 // System.out.println(ass);
                  //  }
                  // System.out.println("#####################################");
                }
              }
            }); /*
                    car.getFloorRequestPanel().addListener(new FloorRequestPanel.Listener()
                    {
                      public void floorRequested(Floor destinationFloor)
                      {
                        float currentHeight = car.getHeight();
                        if (destinationFloor.getHeight() > currentHeight)
                        {
                          addDestination(destinationFloor, Direction.UP);
                        }
                        else if (destinationFloor.getHeight() < currentHeight)
                        {
                          addDestination(destinationFloor, Direction.DOWN);
                        }
                        else
                          throw new RuntimeException("Do we really want to go to the current floor?");
                          // Maybe some day we can just turn off the button
                //        getFloorRequest(floor).setRequested(false, currentTime);
                      }
                    });*/
  }
  public CarController(Car c, float stoppingDist, Listener listener) {
    // TODO Auto-generated constructor stub

    super();
    search = null;
    car = c;
    stoppingDistance = stoppingDist;
    assignments = new CarAssignments(car.getName());

    floors = Building.getFloorList();

    car.getFloorRequestPanel().addListener(listener);
  }
  public CarController(Car c, float stoppingDist, AStarSearch searchServer) {
    super();
    this.search = searchServer;
    car = c;
    stoppingDistance = stoppingDist;
    floors = Building.getFloorList();
    assignments = new CarAssignments(car.getName());

    car.getFloorRequestPanel()
        .addListener(
            new FloorRequestPanel.Listener() {
              public void floorRequested(Floor destinationFloor) {
                List<RemoteCarController> carControllers = new ArrayList<RemoteCarController>();
                RemoteCarController remoteCar =
                    ((RemoteController) getCarController()).getController();
                Assignment ass;
                if (car.getDestination() != null && car.getLocation() == null) {
                  ass = getNearestBase();
                  int di;
                  if (ass.getDirection().isUp()) di = 1;
                  else if (ass.getDirection().isDown()) di = -1;
                  else di = 0;
                  remoteCar.setState(ass.getDestination().getFloorNumber(), di);
                } else if (car.getLocation() != null)
                  remoteCar.setState(car.getLocation().getFloorNumber(), 0);
                else remoteCar.setState(car.getFloorAt().getFloorNumber(), 0);
                HashSet<Assignment> tempAssignments = new HashSet<Assignment>();
                carControllers.add(remoteCar);
                // System.out.println(carControllers);
                for (Iterator i = assignments.iterator(); i.hasNext(); ) {
                  tempAssignments.add((Assignment) i.next());
                }
                tempAssignments.add(new Assignment(destinationFloor, Direction.NONE));
                // System.out.println("Assignment Task:");
                // for (Assignment task:tempAssignments){
                //	System.out.print(task+",");
                // }
                // System.out.println();
                AssignmentTask assignmentTask = new AssignmentTask(carControllers, tempAssignments);
                PlanedControllerList planedControllerList;
                ArrayList<PlanedController> planedControllers = new ArrayList<PlanedController>();
                HashSet<RemoteAssignment> assignmentlists = new HashSet<RemoteAssignment>();
                assignmentlists = assignmentTask.getAssignments();
                // planedControllerList =
                //		JClientController.Search(assignmentTask);
                // planedControllers=planedControllerList.getList();
                try {
                  planedControllerList = search.Search(assignmentTask);
                  planedControllers = planedControllerList.getList();
                } catch (RemoteException e) {
                  e.printStackTrace();
                }
                assignments.removeAll();
                ArrayList<Integer> array = new ArrayList<Integer>();
                array.addAll(planedControllers.get(0).getList());
                for (Integer j : array) {
                  assignments.add(new Assignment((Floor) floors.get(j - 1), new Direction("NONE")));
                }
                setNextDestination();
              }
            });
  }