// Interface for the Vehicle class // CSE143 Spring '01 // Homework 6 #ifndef _VEHICLE_H #define _VEHICLE_H #include "sim_object.h" #include "position.h" // Vehicle: models a vehicle that can travel the roads in the simulation. // Each vehicle keeps track of the vehicle directly ahead of it on the same // road segment (the member "ahead"), and makes sure not to run into it. // This creates a linked list of vehicles in each segment. // This is a subclass of SimObject and implements draw() and tick(). class Vehicle : public SimObject { public: // Construct a vehicle with uninitialized position and heading. Vehicle(); // Construct a vehicle with same position and heading as õ Vehicle(const Vehicle& other); // Set position and heading of this vehicle to 's Vehicle& operator =(const Vehicle& other); // Destructor (empty - no dynamic memory in this class) virtual ~Vehicle(); // Draw the vehicle on the screen virtual void draw(GP142Display& gp); // Update vehicle appearance. virtual void tick(); // Advance the specified distance in pixels, in the current direction. virtual void advance(int distance); // Turn the vehicle to face the new direction. virtual void turn(Direction newHeading); // Move the vehicle to the specified position. virtual void setPosition(Position pos); // Returns the current position. virtual Position getPosition() const; // Returns the current heading. virtual Direction getHeading() const; private: Position pos; // Current screen position Direction heading; // Current driving direction }; #endif