/* File: cars.h
 *
 * This contains the class for a car in the traffic simulation
 */

class Car {
    public:
        int source;                  // where it is leaving from
        int destination;             // where it wants to go
        int departure_time;          // when it will to leave
        int arrival_time;            // when it arrived
        int expected_arrival;        // when it expected to arrive
        bool departed;               // flag that it has left
        bool completed;              // flag that it has completed trip
        int at_intersection;         // time when it reaches next intersection

                                     // set a random source intersection
        void random_source(double *distribution, int size);
                                     // set a random dest. intersection
        void random_destination(double *distribution, int size);
                                     // set a random departure time
        void random_depart(int start, int end);
                                     // choose the route to follow
        void set_route(int size, int *path);
                                     // where is the car currently going
        int current_step() { return route[next_step_of_route]; }
                                     // where will the car next go
        int next_step() { return route[next_step_of_route+1]; }
                                     // the car completed the current step
        void completed_step() { next_step_of_route++; }

        Car() { route = 0; departed = false; completed = false; }
        ~Car() { if (route) delete[] route; }

    private:
        int *route;                 // the route the car will take
        int next_step_of_route;     // index, in route, of where car is on trip
};

