Question: PLS HELP have most of my code but keep getting this error! Heres my code / / Complete the implementation of your MyArrayList class in
PLS HELP have most of my code but keep getting this error!
Heres my code
Complete the implementation of your MyArrayList class in this file
import java.util.NoSuchElementException;
public class MyQueue implements IQueue
private Object queueArray;
private int front;
private int rear;
private int size;
public MyQueue
queueArray new Object;
front ;
rear ;
size ;
public void enqueueObject item
if size queueArray.length
resizeArray;
Add the item to the rear of the queue
rear rear queueArray.length;
queueArrayrear item;
size;
public Object dequeue
if isEmpty
throw new NoSuchElementExceptionQueue is empty";
Remove and return the item from the front of the queue
Object item queueArrayfront;
queueArrayfront null; Clear the reference
front front queueArray.length;
size;
return item;
public Object peek
if isEmpty
throw new NoSuchElementExceptionQueue is empty";
return queueArrayfront;
public int indexOfObject item
for int i ; i size; i
int index front i queueArray.length;
if queueArrayindex null && queueArrayindexequalsitem
return i;
return ;
public int getSize
return size;
public boolean isEmpty
return size ;
private void resizeArray
int newCapacity queueArray.length ;
Object newArray new ObjectnewCapacity;
for int i ; i size; i
newArrayi queueArrayfront i queueArray.length;
queueArray newArray;
front ;
rear size ;
Additional Information
MyQueue
This concrete class will store its elements in either an internal array list or linked list. All such implementation details must be contained in your myQueue java file. You may add any additional fields, methods, and inner classes that you will need to achieve this.
enqueuemethod
Add a new item to end of the queue. For example: given the queue where the value is at the front and the value is currently at the back and an instruction to enqueue the result would be this with the value now at the end of the queue.
dequeuemethod
Remove and return the item currently at the front of the queue. For example: given the queue where the value is at the front and the value is currently at the back and an instruction to dequeue the queue would now look like this and the value would be returned.
Throws a NoSuchElementException if the queue is currently empty when this method is called.
peekmethod
Return but do not remove the item currently at the front of the queue. For example: given the queue where the value is at the front and the value is currently at the back and an instruction to peek the queue would still look like this and the value would be returned.
Throws a NoSuchElementException if the queue is currently empty when this method is called.
indexOfmethod
Return the zerobased number of elements from the front or top of the collection where the specified item is first found. Returns if the item is not found in the collection. For example: given the queue where the value is at the front and the value is currently at the back and the instruction indexOf the value would be returned because the value was found at index element after the front in the queue. For another example: given the queue where the value is at the front and the value is currently at the back and the instruction indexOf the value would be returned because the value is not found in the queue
sizemethod
Returns the number of elements currently stored in the queue.
isEmptymethod
Returns true if there are currently no items stored in this queue, otherwise returns false.
MyQueuejava:: error: MyQueue is not abstract and does not override abstract method siz
e in IQueue
public class MyQueue implements IQueue
error
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
