Coding with java

Part 1: Create the interface “LimitedAccessCollection”, which will define the behavior of collections (like Stacks and Queues) in which only one object can be retrieved at any time. This interface should define three methods: “push”, “pop”, and “print”. The pop method should be used to access whatever element is available in the collection. The push method should be used to add elements to the collection. The print method, obviously, should be used to print the elements in the collection (in order).

Part 2: Create two classes with the following signatures:

● public class Stackimplements LimitedAccessCollection{

● public class Queue implements LimitedAccessCollection{

These classes should use a LinkedList ( either the LinkedList class available in java.util or a LinkedList class you create is fine) to implement a stack and a queue respectively. A stack is a collection in which the object added most recently is the object that is returned by the pop method, and a queue is a collection in which the least recently added object is returned by the pop method.

Part 3: Create a main method which uses the classes you just wrote to create a queue and a stack of String objects. Add 5 random strings to each (the same 5 strings to each collection in the same order), printing each collection with the print method each time. Then use the pop method to gradually empty each collection, printing the word removed from each and whatever remains in each collection at every step.

"Get 15% discount on your first 3 orders with us"
Use the following coupon
"FIRST15"

Order Now