Question
Add the following methods to the ArrayBoundedStack classAdd the following methods to the ArrayBoundedStack class, and create atest driver for each to show that they
Add the following methods to the ArrayBoundedStack classAdd the following methods to the ArrayBoundedStack class, and create atest driver for each to show that they work correctly. In order to practiceyour array related coding skills, code each of these methods by accessingthe internal variables of the ArrayBoundedStack, not by calling thepreviously defined public methods of the class.
String toString()creates and returns a string that correctly represents thecurrent stack. Such a method could prove useful for testing and debuggingthe class and for testing and debugging applications that use the class.Assume each stacked element already provided its own reasonabletoString method.
int size()returns a count of how many items are currently on the stack.Do not add any instance variables to the ArrayBoundedStack class in orderto implement this method.
void popSome(int count)removes the top count elements from the stack;throws StackUnderflowException if there are less than count elements onthe stack.
boolean swapStart()if there are less than two elements on the stackreturns false; otherwise it reverses the order of the top two elements on thestack and returns true.T
poptop( )the classic pop operation, if the stack is empty it throwsStackUnderflowException; otherwise it both removes and returns the topelement of the stack
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started