1) Create a LLQueue class that implements the interface below. 2) The implementa
ID: 3702267 • Letter: 1
Question
1) Create a LLQueue class that implements the interface below. 2) The implementation must be a linked list-based. 3) The implementation must add a max_capacity to prevent users from adding over the limit. 4) For this program use Tool objects as your testing data. 5) Add a Driver/Demo/Test class to test all the methods of LLQueue. 6) Test your project and screen-capture your sample testing to be sent along with the projectPlease Post the test as a picture and the code as a text so I can copy
1) Create a LLQueue class that implements the interface below 2) The implementation must be a linked list-based 3) The implementation must add a max_capacity to prevent users from adding over the limit. 4) For this program use Tool objects as your testing data. 5) Add a Driver/Demo/Test class to test all the methods of LLQueue 6) Test your project and screen-capture your sample testing to be sent along with the project 7) Turn-in your project in a compressed file ".zip" by email 8) Due date: 04.15.2018
Explanation / Answer
public interface QueueInterface<T> {
public void enqueue(T newEntry);
public T dequeue();
public T getFront();
public boolean isEmpty();
public void clear();
public int size();
public T[] toArray();
public String toString();
}
-------------------------------------------------------------------------
public class LLQueue implements QueueInterface<Object> {
private LinkedList<Object> elements = new LinkedList<Object>();
@Override
public void enqueue(Object newEntry) {
elements.add(newEntry);
}
public Object dequeue() {
return elements.removeFirst();
}
public Object getFront() {
return elements.getFirst();
}
public boolean isEmpty() {
return elements.isEmpty();
}
public void clear() {
elements.clear();
}
public int size() {
return elements.size();
}
@Override
public Object[] toArray() {
return elements.toArray();
}
@Override
public String toString() {
return "LLQueue [elements=" + elements + "]";
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.