I need some advice with an exercise that I am doing which I have got stuck with and can not get past what ever I try so was hoping that someone may be able to help. My tutor says I am very close but it does not feel like it!
I need to implement a method called reset()
this method should return a new empty TrafficQueue (which is designed as an ArrayList) the same size as the current one.
I must stick to the method signatures specified in the interface, so must use
public ThingBeingSimulated reset() { ... }
The class ThingBeingSimulated is a programme that I have been give to allow the TrafficQueue to be shown on the screen. TrafficQueue is the class and queue should be the instance of the class. I have tried all of the following which give a range of compilation errors.
public ThingBeingSimulated reset(){ return this.queue(size); }
public ThingBeingSimulated reset(){ return new TrafficQueue(size);}
public ThingBeingSimulated reset(){ return new TrafficQueue(queue.size);}
public ThingBeingSimulated reset(){ return new queue(queue.size):}
public ThingBeingSimulated reset(){ queue = new ArrayList<RoadVehicle>(size); return queue(size); }
public ThingBeingSimulated reset(){ return new ThingBeingSimulated(queue.size);}