GenericStack
Open the project named Ch12_ex3_GenericStack that’s in the ex starts folder
Create a new class names GenericStack that specifies the type variable that provides for
genericDeclare a linked list that will hold the elements in the stack. Then use the linked list to implement the methods ….push(element), pop(), peek (), size()
Create a class that uses the GenericStackApp Class. Then, declare a generic stack at the beginning of the main method that will store String objects
Add code to main method that uses the push method to add at least three items to the stack, after each is added, display it s value in the console(use a string literal for this). Then use the size method to return the number of items in the stack and display it value.
Use the ‘peek” method to return the first item and display that item, and use the size method to return the number of items again and display that value.
Use the pop method to return each item, displaying it as its returned, and display the number of items one more time.
12 years ago
Purchase the answer to view it

- ch12_ex3_genericstack.zip