Assignment Objectives

After completing this assignment the student should be able to,

  • Write concrete classes that implement Java Interfaces according to specifications given in UML.
  • Implement a last-in-first-out (LIFO) stack class in java.
  • Implement a first-in-first-out (FIFO) queue class in Java.

Assignment Requirements

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.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.