Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

Students also viewed these Databases questions