Add the following methods to theArrayBoundedQueueclass, and create a test driver for each to show that they work correctly. In order to practice your array coding skills, code each of these methods by accessing the internal variables of theArrayBoundedQueue, not by calling the previously defined public methods of the class.
ArrayBoundedQueue
String toString()creates and returns a string that correctly represents the current queue. Such a method could prove useful for testing and debugging the class and for testing and debugging applications that use the class. Assume each queued element already provides its own reasonabletoStringmethod.
String toString()
toString
int space()returns an integer indicating how many empty spaces remain in the queue.
int space()
void remove(int count)removes the frontcountelements from the queue, and throwsQueueUnderflowExceptionif there are less thancountelements in the queue.
void remove(int count)
count
QueueUnderflowException
boolean swapStart()returnsfalseif there are less than two elements in the queue; otherwise it reverses the order of the front two elements in the queue and returnstrue.
boolean swapStart()
false
true
boolean swapEnds()returnsfalseif there are less than two elements in the queue; otherwise it swaps the first and last elements of the queue and returnstrue.
boolean swapEnds()
Notes on doing the assignment:
Note:
attach/upload the following files to your assignment:
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here