I would like to know any suggestions about the implementation of a queue of cars. For now i have just one car that moves correctly in the screen, we are using Programming oriented object. What I need is to display more than one car in a road, for this i designed 3 classes Queue, Iterator and Node.
1.Queue:
public:
Queue();
~Queue();
bool add(Car car);
Car get();
Car& getFirst() const;
Car& getFinal() const;
bool isEmpty() const;
Iterador getStart() const;
private:
Node* m_first;
Node* m_final;
2.Iterator:
public:
Iterator();
~Iterator();
Iterator(Node* position);
void next();
Car& getCar() const;
bool isNull() const;
private:
Node* m_position;
3.Node:
public:
Node();
~Node();
Node(Car car, Node* next);
void setCar(Car car);
void setNext(Node* next);
Car getCar() const;
NodeVehicle* getNext() const;
private:
Car m_car;
Node* m_next;
There is a main project where i call all the classes, the Car class allows me to draw and move the car in the x-axis... The mentioned classes have been implemented but the problem is how to use them, I know that i can't paste the whole source code here, but it would be helpful if there's a topic that explains this very well.