I need help writing these Java classes. Thanks Array Based Queue Class - You wil
ID: 3810317 • Letter: I
Question
I need help writing these Java classes. Thanks
Array Based Queue Class - You will write the ArrayBasedQueue.java class which will implement the Queue Interface. Please note that Queue Interface extends the Iterable Interface.
Linked Queue Class - You will write the LinkedQueue.java class which will implement the Queue Interface. Please note that Queue Interface extends the Iterable Interface. Also note that the Linked Queue Class should be a Doubly Linked Queue
Node Class - You will write the Node.java. Please note that the Node Class is a node for a Doubly Linked Queue.
Information On The Iterable Interface - The Iterable Interface requires you to implement one method Iterator iterator().
Queue Interface Methods
Iterable Interface Method
Node Class
Method Summary All Methods Instance Methods Abstract Methods Modifier and Type Method and Description dequeue Retrieves and removes the element at the head ofthis queue. dequeue int index Retrieves and removes the element at the specified index. enqueue (E e) void. Adds the specified element into the stack if it is possible to do so immediately without violating capacity restrictions, otherwise, throwing an IllegalStateException if no space is currently available or NullPointerException ifthe specified element is null. is Empty boolean This method is called to determine if the queue is empty. peek. Retrieves, but does not remove, the head of this queue. void remove All Removes all elements from the queue. int size This method is called to obtain the count of elements in the list.Explanation / Answer
Node.java
package linkedlist;
public class Node<E> {
Node<E> previous;
E data;
Node<E> next;
public Node(Node<E> previous, E data, Node<E> next) {
super();
this.previous = previous;
this.data = data;
this.next = next;
}
public Node<E> getPrevious() {
return previous;
}
public void setPrevious(Node<E> previous) {
this.previous = previous;
}
public E getData() {
return data;
}
public void setData(E data) {
this.data = data;
}
public Node<E> getNext() {
return next;
}
public void setNext(Node<E> next) {
this.next = next;
}
}
ArrayBasedQueue.java
package linkedlist;
import java.util.Collection;
import java.util.Iterator;
import java.util.Queue;
public class ArrayBasedQueue<E> implements Queue<E> {
@Override
public boolean addAll(Collection<? extends E> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public void clear() {
// TODO Auto-generated method stub
}
@Override
public boolean contains(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean containsAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}
@Override
public Iterator<E> iterator() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean remove(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean removeAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean retainAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public int size() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object[] toArray() {
// TODO Auto-generated method stub
return null;
}
@Override
public <T> T[] toArray(T[] a) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean add(E e) {
// TODO Auto-generated method stub
return false;
}
@Override
public E element() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean offer(E e) {
// TODO Auto-generated method stub
return false;
}
@Override
public E peek() {
// TODO Auto-generated method stub
return null;
}
@Override
public E poll() {
// TODO Auto-generated method stub
return null;
}
@Override
public E remove() {
// TODO Auto-generated method stub
return null;
}
}
LinkedQueue.java
package linkedlist;
import java.util.Collection;
import java.util.Iterator;
import java.util.Queue;
public class LinkedQueue<E> implements Queue<E>{
@Override
public boolean addAll(Collection<? extends E> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public void clear() {
// TODO Auto-generated method stub
}
@Override
public boolean contains(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean containsAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}
@Override
public Iterator<E> iterator() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean remove(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean removeAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean retainAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public int size() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object[] toArray() {
// TODO Auto-generated method stub
return null;
}
@Override
public <T> T[] toArray(T[] a) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean add(E e) {
// TODO Auto-generated method stub
return false;
}
@Override
public E element() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean offer(E e) {
// TODO Auto-generated method stub
return false;
}
@Override
public E peek() {
// TODO Auto-generated method stub
return null;
}
@Override
public E poll() {
// TODO Auto-generated method stub
return null;
}
@Override
public E remove() {
// TODO Auto-generated method stub
return null;
}
}