The stack is a classic data structure that is encountered in computer science. It implements a FILO / LIFO mechanism using its push and pop methods. Although linked lists and stacks are often used for radically different purposes, it is possible to implement the stack using a linked list. At this time you are asked to implement class Stack using class Inklst. You are being provided with Inklst.jar, a Java archive containing all the classes needed for the Inklst and its supporting classes, including BaseLnklst.class, Lnklst.class, Node.class and Data.class[1]. Use whatever OO techniques you deem appropriate. Your implementation of Stack must contain the following:
This is to be a multi-file project. Stack.java will contain the actual implementation. You will also write a driver program that continuously re-prompts the user to enter the name of the file containing the binary data[3]. The driver then instantiates an object of type Stack and invokes its createFromFile method passing it the character string containing the file name. Let the sample output which follows guide your design. As always, follow the good rules of program construction. Comment your code as necessary and be efficient so as not to waste memory or cpu cycles. Use reserved words such as final to insure that the functions cannot change parameters that should be immutable. Always have appropriate exception handling.
Enter the file you want read - data1000.bin
Preparing to read data1000.bin
In total 1000 records were pushed onto the stack.
Do you wish to continue with another file (Y/N)? - y
Enter the file you want read - data 2000.bin
data2000.bin could not be opened.
In total 1000 records were pushed onto the stack.
Do you wish to continue with another file (Y/N)? - y
Enter the file you want read - data 20000.bin
Preparing to read data 20000.bin
In total 21000 records were pushed onto the stack.