Re: java class hierarchy



On Sat, 21 Jul 2007 18:43:24 +0200, Thomas wrote:
In the main loop I have to keep the refrence to the object taken from
FIFO, and here is the problem : what type of refrence it should be ? Not
a symbol because it is abstract, but it implements the Evaluate
interface. I confused. Any suggestions, please ?

What do you mean, "Not a symbol because it is abstract"? Any type can be
used for reference, including abstract classes and interfaces. This would
be partial code for what I think you want to do:

LinkedList<Symbol> stack = new LinkedList<Symbol>();
Queue<Symbol> queue = new LinkedList<Symbol>();
// ... Fill queue ...
while (!queue.isEmpty()) {
Symbol head = queue.remove();
if (head instanceof Operand) {
stack.addLast(head);
} else if (head instanceof Function) {
// ... manipulate stack, etc.
}
}
.