After completing this assignment the student should be able to,
For this assignment you are given the following Java source code files:
CSE205_Assignment03.java (This file is complete - you will make no changes to this file)
IStack.java (This file is complete you will make no changes to this file)
IQueue.java (This file is complete you will make no changes to this file)
MyStack.java (you must complete this file)
MyQueue.java (you must complete this file)
The specifications for the files are given below (including the UML diagram on the following page).
Special requirements:
Both MyStack and MyQueue Classes
1. size method
a. Returns the number of items in the collection.
2. empty method
a. Returns true if the size of the collection is zero; otherwise returns false.
3. peek method
a. Returns the item at the front or top of the collection.
b. Throws a NoSuchElementException is the collection is empty
4. search method
a. Returns the (zero-based) number of elements from the front or top of the collection where the specified item is first found. Returns -1 if the item is not found in the collection.
MyStack
1. You must implement the IStack interface as either a linked list or an array list (refer to your work from Assignment 02). Your MyStack must not be arbitrarily limited to any fixed size at run-time.
2. push method
a. Insert the new item at the top of the stack.
3. pop method
a. Remove and return the item at the top of the stack.
b. Throws a NoSuchElementException is the stack is empty
MyQueue
1. You must implement the IQueue interface as either a linked list or an array list (refer to your work from Assignment 02). Your MyQueue must not be arbitrarily limited to any fixed size at run-time.
2. add method
a. Insert the new item at the back of the queue.
3. remove method
a. Remove and return the item at the front of the queue.
b. Throws a NoSuchElementException is the queue is empty
UML Class Diagram see image.