[Bluej-discuss] 7.26 - The stack, problem

ric104 ric104 at ecs.soton.ac.uk
Tue Nov 21 12:10:50 GMT 2006


Thanks, it worked so I did this:

currentRoom = (Room)history.pop 

and it worked a treat!

Thanks for your advice

Roland

On Tue, 21 Nov 2006 11:56:12 +0100, Denis BUREAU <Denis.Bureau at wanadoo.fr> wrote:
> Roland,
> 
> If history was declared as a stack of rooms,
> currentRoom = history.pop(); should work.
> 
> If it's declared as a "stack",
> you need to cast to Room
> the result of history.pop();
> 
> Hope that helps.
> 
> At 21/11/2006 10:09, ric104 wrote:
>>Hi
>>
>>I am on question 7.26 implementing the "back" command for
>>zuul-better. I have managed to create a history of rooms by creating
>>a new stack called history and adding a room to the stack by using
>>the push method.
>>
>>history.push(currentRoom);
>>
>>I am then echoing to check the stack is being filled, via
>>
>>System.out.println(history);
>>
>>It is working
>>
>>But when I try to pop off the stack I always get an error. I try to
>>pop off the stack into currentRoom Room object.
>>
>>           currentRoom = history.pop();
>>            System.out.println(currentRoom.getLongDescription());
>>
>>I keep getting an incompatible types error, I cant think how else to
>>do this, and would appreciate some advice on what other options I might
> have.
>>
>>Thanks
>>
>>Roland Clothier
>>2nd Year ITO Student
>>University of Southampton
>>
>>_______________________________________________
>>mailing list bluej-discuss at bluej.org
>>To unsubscribe or change your preferences, go to
>>http://lists.bluej.org/mailman/listinfo/bluej-discuss
> 
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss



More information about the bluej-discuss mailing list