Design a class called Stack (the class java file should be called Stack.java) that encodes an extended version of a stack class, with the following (exact) fields and methods/constructors:
Fields and Methods | Description | |
Fields | Data | Hold the data, an array of integers |
Top | The top of the stack | |
Size | The size of the stack | |
Methods | Stack | A constructor with no parameters that initialized the fields of the stack |
Stack | A constructor that creates a stack of a size given by the parameter | |
Push | Insert the node (given by the parameter) to the Stack | |
Pop | Fetch a node from the stack and returns it | |
ShowAll | Output all the values from the stack | |
Empty | Reinitialize the stack to the empty stack | |
IsEmpty | Test if the stack is empty (underflow condition) | |
Peek | Peek at the stack | |
Find | Find the node on a certain position on the stack (given by parameter) |
Design a class called Queue (the class java file should be called Queue.java) that encodes an extended version of a queue class, with the following (exact) fields and methods/constructors:
Fields and Methods | Description | |
Fields | Data | Hold the data, an array of integers |
Size | The size of the queue | |
Front | The front of the queue | |
Rear | The rear of the queue | |
Methods | Queue | A constructor with no parameters that initialized the fields of the queue |
Queue | A constructor that creates a queue of a size given by the parameter | |
Enque | Insert the node (given by the parameter) to the queue | |
Deque | Fetch a node from the queue and returns it | |
ShowAll | Output all the values from the queue | |
Empty | Reinitialize the stack to the empty queue | |
IsEmpty | Test if the queue is empty (underflow condition) | |
Peek | Peek at the queue | |
Find | Find the node on a certain position on the queue (given by parameter) |
After you design the stack, and queue classes. Please design a program/project/driver class which is called Main, that will create an object of both of the classes, and the functionality of both classes. Also, add the stack and queue to the Main project, and add the code to the project/driver class.