Hi
I need a expression tree class that conver infix expressions to postfix and prefix, and i already have this classes:
public class Stack<E>{ private int d = -1; private int MAX = 100; private int size = 0; private E[] stack; @SuppressWarnings("unchecked") public Stack(int size){ stack = (E[])new Object[size]; this.size = size; } public Stack(){ this(MAX); } public void push(E o) throws OverflowStackException{ if (size == (d+1)) throw new OverflowStackException(); d++; stack[d] = o; } public E top() throws EmptyException{ if(d == -1) throw new EmptyException(); return stack[d]; } public E pop() throws EmptyException{ if(d == -1) throw new EmptyException(); d--; return stack[d+1]; } public int size(){ return d+1; } public boolean empty(){ return d == -1; } }
public class BTree<E>{ E element; BTree<E> dir; BTree<E> esq; public BTree(){ this(null); } public BTree(E x){ element = x; esq = null; dir = null; } public BTree(E x, BTree<E> d, BTree<E> e){ element = x; dir = d; esq = e; } public E element() throws InvalidNode{ if(this == null) throw new InvalidNode("Null node"); return element; } public void setElement(E x){ element = x; } public void setDir(BTree<E> d){ dir = d; } public void setEsq(BTree<E> e){ esq = e; } public BTree<E> getDir(){ return dir; } public BTree<E> getEsq(){ return esq; } }
and now i need that class desesperatly i didnīt get anything yet and iīm getting out of time, someone please help me??
I need to use the String Tokenizer and is all i can use from java.util.
Thanks in advance