Friday, 19 August 2011

NEXT LAB PROGRAMS (20.08.2011 and 23.08.2011)


4. Design a Java interface for ADT Stack. Develop two different classes that implement this interface, one using array and the other using linked-list. Provide necessary exception handling in both the implementations.

ALGORITHM
STEP 1: Create an interface which consists of three methods namely PUSH, POP and
    DISPLAY
STEP 2: Create a class which implements the above interface to implement the concept
              of stack through Array
STEP 3: Define all the methods of the interface to push any element, to pop the top
               element and to display the elements present in the stack.
STEP 4: Create another class which implements the same interface to implement the concept of stack through linked list.
STEP 5: Repeat STEP 4 for the above said class also.
STEP 6: In the main cl
ass, get the choice from the user to choose whether array
                implementation or linked list implementation of the stack.
STEP 7: Call the methods appropriately according to the choices made by the user in the
                previous step.
STEP 8: Repeat step 6 and step 7 until the user stops his/her execution

No comments:

Post a Comment