File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

programming to the interface

 
Dianne Gerrelli
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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);}

I would be grateful for any help what so ever.



 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12022
25
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
There's no need to make the same post in multiple forums - in fact, it's generally discouraged. You can read why here.

I think we're gonna close this one, as there are responses coming in this one.
 
I agree. Here's the link: http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic