Question
Hey, I am working on a project that requires to write a class that implements a stack interface. Interface I wrote is given below even
Hey, I am working on a project that requires to write a class that implements a stack interface. Interface I wrote is given below even though I am not really sure if I need isFull or isEmpty.
However The most important aspect of the project is I CAN NOT USE ANY EXCEPTION for underflow and overflow.
I have to handle errors inside push, pop and top method. Here push and pop method will return true if it can be pushed and popped and if it can't it will return false. if there is top element it will return it if it desnt have it will return null.
How do i go about writing this class without exceptions as well as test method for this class? I also dont understand if it will really make any difference with exceptions or handling errors without it.
public interface MyIntface
void push ( T members) ;
void pop() ;
T top();
boolean isFull();
boolean isEmpty();
}
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