1 #include "elevator.hpp"
9 // Intentionally Left Empty
12 void Elevator::stop_at (int floor, enum direction _direction)
14 std::cout << "Adding Stop: Floor=" << floor << " Dir=" << _direction << std::endl;
15 //_stops.insert (Stop(floor, _direction));
16 _stops.push_back (Stop(floor, _direction));
20 * Will check if direction needs to be changed, then change it.
22 * Will move this Elevator one step in the correct direction.
24 * The correct direction is defined based on the current direction:
26 * IDLE: Move in the direction that has the most stops
27 * - Ex: if there are 10 stops above us, and two below, move DOWN
31 * DOWN: Move downwards
33 void Elevator::move ()
35 std::cout << "move()" << std::endl;
38 enum direction Elevator::find_best_direction ()
40 /* Make sure that the current direction is IDLE */
41 if (_direction != IDLE)
42 throw bad_direction();
44 std::vector<Stop>::const_iterator it;
47 for (above=0, below=0, it = _stops.begin(); it != _stops.end(); it++)
50 if (_pos.lowerThan (*it))
53 if (_pos.higherThan (*it))
58 std::cout << "above=" << above << " below=" << below << std::endl;
69 /* vim: set ts=4 sts=4 sw=4 noexpandtab textwidth=112: */