Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Java Code -Queue Class instructions if needed Description: As we recently built our own Queue implementation, it would only make sense to also build our

image text in transcribed

Java Code

-Queue Class instructions if needed

image text in transcribed

Description: As we recently built our own Queue implementation, it would only make sense to also build our own custom Stack implementation Requirements: Using the same design pattern as was used for your Queue class, create a Stack class with the aforementioned name that implements the following methods. Your stack needs to grow as necessary 1. a. +MyStack() b. +peek():Object c. +push(Object):void d. +pop():Object e. +getSize():int f. +getCapacity():int g. +getRemainingCapacity():int h. +isFull():Boolean i. tisEmpty():Boolean j. +toString():String k. +addAll(ObjectlI):boolean - adds all objects in the array to the top of the stack in the order they were given in I. +contains(Object):boolean- returns true if the object m. +containsAlI(Object[]):boolean - returns true if all the n. +toArray():Objectl]- returns an array representation of the array passed exists in the stack objects in the array are contained in the stack the stack, where index 0 is the bottom of the stack Packaging Fully qualified class names are listed below . edu.ben.homeworks.homework5.MyStack.java Description: As we are beginning to use objects as tools we can build and utilize in our applications let's apply that to a data structure such as a queue. Implement your own array based Queue class called: MyQueue with the required methods below Make sure you fully test your functionality using a complement of JUnit test methods in a JUnit test case called: MyQueueTest Requirements: 1. Create a class called "MyQueue 2. Create an array of type int 3. Create the following methods a. Constructor-Takes an int representing the size of the queue/array b. peek-Returns the next value in the queue (Integer), without removing it, or null if empty. c. enqueue-Takes an int value and inserts it at the tail of this queue, returns true/false. d. getSize-Returns an int of the number of elements in the queue. eisFull-Returns true if the queue is full, false otherwise f. isEmpty-Returns true if the queue is empty, false otherwise. dequeue Removes the next element in the queue (Integer) and returns it, throws Exception if empty Returns the capacity of the queue as an int. i. getRemainingCapacity Returns number of additional elements that this queue can accept as an int. j. getLargest- Returns the largest value in the queue (Integer) or null if the queue is empty. k. getSmallest - Returns the smallest value in the queue (integer) or null if the queue is empty toString-Override this method to print an appropriately formatted text representation of the current state of the queue. Ex.MyQueue L. [array=1,2,3]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions