Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

//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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago