[Bluej-discuss] 7.26 - The stack, problem

ric104 ric104 at ecs.soton.ac.uk
Tue Nov 21 09:09:06 GMT 2006


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



More information about the bluej-discuss mailing list