All of the Elevators need a unique number so that they can call into the
GUI and update their positions, etc.
Signed-off-by: Ira W. Snyder <devel@irasnyder.com>
#include "elevator.hpp"
-Elevator::Elevator ()
+Elevator::Elevator (int elevator_number)
: state_(STATE_IDLE)
, wait_(0)
, direction_(IDLE)
, position_()
, stops_()
+ , number_(elevator_number)
{
// Intentionally Left Empty
}
-Elevator::Elevator (int starting_floor)
+Elevator::Elevator (int starting_floor, int elevator_number)
: state_(STATE_IDLE)
, wait_(0)
, direction_(IDLE)
, position_(starting_floor)
, stops_()
+ , number_(elevator_number)
{
// Intentionally Left Empty
}
class Elevator
{
public:
- Elevator ();
- Elevator (int starting_floor);
+ Elevator (int elevator_number);
+ Elevator (int starting_floor, int elevator_number);
void stop_at (Stop &stop);
float distance_from (Position& pos) const;
State state_;
int wait_;
+ /* Elevator Number: Used to make calls into the GUI */
+ int number_;
+
static const float ELEVATOR_STEP = 0.1;
};
/* Create and add all of the elevators */
for (int i=0; i<number_of_elevators_; i++)
- elevators_.push_back (Elevator());
+ elevators_.push_back (Elevator(i));
}
static int choose_random_number_in_range (int low, int high)