Question: //stack public class Stack { private Node top = null; private int size = 0; public boolean isEmpty() { return (top ==null); } public Object

 //stack public class Stack { private Node top = null; private

//stack

public class Stack {

private Node top = null;

private int size = 0;

public boolean isEmpty() {

return (top ==null);

}

public Object top() {

return top.ob;

}

public void push (Object element) {

Node tmp = new Node (element);

tmp.Next=top;

top=tmp;

size++;

}

public Object pop() {

Node tmp = top;

top = top.Next;

size--;

return (Token)tmp.ob;

}

}

//Queue

public class Queue {

private int rear = -1;

private int front = 0;

private int size = 1024;

private Object s [] = new Object[size];

public boolean isEmpty() {

return front == (rear+1) % size;

}

public void enqueue (Object Element) {

rear = (rear+1) % size;

s[rear] = Element;

}

public Object dequeue() {

Object Element = s[front];

s[front] = null;

front = (front +1) % size;

return Element;

}

public String toString() {

String temp = "";

for (int i = 0; i

if (s[i]!=null) {

temp += s[i].toString() + " ";

}

}

return temp;

}

}

The Java class library: The Java Class Library is a set of dynamically loadable libraries that Java application programs can call at runtime. Like other standard code libraries, Java class library provides the programmer a well-known set of functions to perform common tasks, such as maintaining lists of items or performing complex string parsing. For Java 1.5 or later, some generic classes and generic interfaces are included in the Java class library. Examples import java.util.*; public class Stack extends Vector public Stack0;/ constructor public Boolean empty0; public E peek0; public E popO; public E push(E item); public class LinkedList extends AbstractSequentialList implements List E>, Queue, Cloneable, Serializable { public LinkedList0;// constructor public E getFirst0 public E removeFirst0; public void addLast(E item); public Boolean isEmpty0: The programming assignment: In your l ab07, 1. 2. 3. 4. 5. Replace your stack of Object with the generic class Stack Replace your queue of Object with the generic class LinkedList Replace Post.toString(0 method with a for-each loop Replace your exception classes with the following exception class. Remove all unnecessary type casts enum errorType ExcessLeftParenthesis, ExcessRightParenthesis, ExcessOperator, ExcessOperand); class infixException extends Exception { private errorType etype; public infixException(errorType et) / constructor etype et; public String toStringO { return etype.name0; The Java class library: The Java Class Library is a set of dynamically loadable libraries that Java application programs can call at runtime. Like other standard code libraries, Java class library provides the programmer a well-known set of functions to perform common tasks, such as maintaining lists of items or performing complex string parsing. For Java 1.5 or later, some generic classes and generic interfaces are included in the Java class library. Examples import java.util.*; public class Stack extends Vector public Stack0;/ constructor public Boolean empty0; public E peek0; public E popO; public E push(E item); public class LinkedList extends AbstractSequentialList implements List E>, Queue, Cloneable, Serializable { public LinkedList0;// constructor public E getFirst0 public E removeFirst0; public void addLast(E item); public Boolean isEmpty0: The programming assignment: In your l ab07, 1. 2. 3. 4. 5. Replace your stack of Object with the generic class Stack Replace your queue of Object with the generic class LinkedList Replace Post.toString(0 method with a for-each loop Replace your exception classes with the following exception class. Remove all unnecessary type casts enum errorType ExcessLeftParenthesis, ExcessRightParenthesis, ExcessOperator, ExcessOperand); class infixException extends Exception { private errorType etype; public infixException(errorType et) / constructor etype et; public String toStringO { return etype.name0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!