Threshold code was wrong
[cs356-p1-elevator.git] / elevatorcontroller.cpp
index 79418ba..9134efb 100644 (file)
@@ -36,8 +36,7 @@ void ElevatorController::call_elevator_to (int floor, Direction direction)
        /* Find all elevators with "low load" */
        for (it=elevators_.begin(); it != elevators_.end(); it++)
        {
-               std::cout << "loop1" << std::endl;
-               if (it->getLoad() < max_load)
+               if (it->getLoad() <= max_load)
                        low_load_elevators.push_back (&(*it));
        }
 
@@ -53,7 +52,6 @@ void ElevatorController::call_elevator_to (int floor, Direction direction)
                /* Find the closest lightly loaded elevator */
                for (lle_it = low_load_elevators.begin(); lle_it != low_load_elevators.end(); lle_it++)
                {
-                       std::cout << "loop2" << std::endl;
                        if ((*lle_it)->distance_from (requested_stop) < distance)
                        {
                                found = true;
@@ -197,4 +195,15 @@ void ElevatorController::move_elevators ()
                it->move();
 }
 
+bool ElevatorController::oneElevatorWillStillStopAt (int floor, Direction direction) const
+{
+       ElevatorList::const_iterator it;
+
+       for (it=elevators_.begin(); it!=elevators_.end(); it++)
+               if (it->willStopAt (floor, direction))
+                       return true;
+
+       return false;
+}
+
 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */