Question: Design a class named Intstack that implement the following interface called ILifo: public interface ILifo{ public int getLength ( ); public boolean isEmpty ( );

Design a class named Intstack that implement the following interface called ILifo:
public interface ILifo{
public int getLength ( );
public boolean isEmpty ( );
public void push(int num);
public int pop( );
public int getCapacity( );
public int setCapacity (int newCapacity);
}
 Design a class named Intstack that implement the following interface called
ILifo: public interface ILifo{ public int getLength ( ); public boolean isEmpty
( ); public void push(int num); public int pop( ); public int

Homework 12 ILifo Interface Objectives: .Practice interface implementation. ign a class named IntStack that implement the following interface called Ilifo: public interface ILifo public int getLength) public boolean isEmpty) public void push (int num) public int pop ( public int getcapacity) public int setcapacity(int newcapacity) The ILifo interface serves to specify a special kind of data structure for storing a collection of integers. It is unique in the insertion and deletion of collection elements. An element can be added to the collection through the push method. The pop method is to remove the most recently addecd integer that was not yet removed. All ILifo methods are described as below: . public int getLength () .public boolean isEmpty() . public void push (int num) o Return the number of elements (i.e., integers) currently in the data structure. o Return true if the data structure is currently empty (i.e., has no element) o Add the passed-in integer to the collection. when the collection is full, this method should signal the caller and reject the request. public int pop () Remove the most recently added integer from the collection and return it. When the collection is empty, this method should signal the caller and reject the request. o o e int getCapacity) Return the capacity of the data structure, that is, the maximum amount of integers the data structure can hold. For example, if the capacity is 100, then the data structure can contains at most 100 integers. Once it contains 100 integers, no more elements can be added before the data structure is popped o int setcapacity(int newcapacity) is used to expand the current data structure for increasing its capacity. The implementing class has to reallocate storage for existing elements and the desired additional capacity. For example, if the capacity before calling setcapacity is 100, calling setCapacity (200) would result in increasing the total capacity to 200. This method is also responsible for copying all existing elements to the newly allocated storage without compromising the ordering and contents of the collection

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!