X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=elevatorcontroller.cpp;h=9134efbdd557550efb54a8f9770fc364b89ca1e0;hb=f95be7131a6221491745f0a001f45589aa6acca3;hp=79418ba583e88c6a81fc14353fa451557dd46a4d;hpb=14164058f22ba9fe64df2eb0a1dc46840d0faffb;p=cs356-p1-elevator.git diff --git a/elevatorcontroller.cpp b/elevatorcontroller.cpp index 79418ba..9134efb 100644 --- a/elevatorcontroller.cpp +++ b/elevatorcontroller.cpp @@ -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: */