Write a class MyArrayQueue that Inherit the ArrayBoundedQueue class show in screen shot and such that all the following methods are implemented in java: public String toString(); // Creates and returns a string that correctly represents the current queue. public void remove(int count); // Removes the front count elements from the queue. // Throw QueueUnderflowException with message of "Less than count elements in queue." //if there are less than count elements in the queue. public void reQueue(); // Dequeue an element from front, and enqueue the element back to rear of the queue. // Throw QueueUnderflowException with message of "No element in queue." // if there is no element in the queue. public void clear(); // Clear entire queue. public void reverse(); // Reverse queue content. Hint: you may use LinkedStack ADT. } public int space(); //return how many open spaces does the queue have still available.
Write a class MyArrayQueue that Inherit the ArrayBoundedQueue class show in screen shot and such that all the following methods are implemented in java:
public String toString();
// Creates and returns a string that correctly represents the current queue.
public void remove(int count);
// Removes the front count elements from the queue.
// Throw QueueUnderflowException with message of "Less than count elements in queue."
//if there are less than count elements in the queue.
public void reQueue();
// Dequeue an element from front, and enqueue the element back to rear of the queue.
// Throw QueueUnderflowException with message of "No element in queue."
// if there is no element in the queue.
public void clear();
// Clear entire queue.
public void reverse();
// Reverse queue content. Hint: you may use LinkedStack ADT.
}
public int space();
//return how many open spaces does the queue have still available.
![public class ArravReuededQURUR<T> implements Queuelotertare<T>
{
protected final int DEFCAP = 100; // default capacity
protected TH elements;
// array that holds queue elements
protected int wMElenents = lin/ number of elements in this queue
protected int front = Qin
protected int ein
// index of front of queue
/ index of rear of queue
public AcravBevodedQueHAU
elements = (TI)) new Object[DEFCAP];
rear = DEFCAP - 1;
}
public ArravBouodedQveralint vaxsize)
{
elements = (T)) new Object[maxsie);
rear = VaxSize - 1;
}
public void enguRuelT element)
// Throws QyeyevertlowExsertien if this queue is full;
// otherwise, adds element to the rear of this queue.
{
if (İSEUW)
throw new QueveevertlowExcertieal"Enqueue attempted on a full queue.");
else
{
rear = (rear + 1) % elements leneth:
elements[rear] = element;
OwDElements = QDElements+ 1;
}
public T deguRue)
// Throws QueyeUoderflbwExsertien if this queue is empty;
// otherwise, removes front element from this queue and returns it.
if (iŞEmotu)
throw new QueuellodertlowExcertienl"Dequeue attempted on empty queue.");
else
{
T toReturn = elements[front];
elements[front] = null;
front = (front + 1) % elementsleneth:
wDElements = wmElements- 1;
return toRetua
}
}
public booleao isEMptx)
// Returns true
this queue is empty; otherwise, returns false.
{
return (qumElemAnts== 0);
public boelean İSEUW
// Returns true if this queue is full; otherwise, returns false.
{
return (QumElements== elementsleneth);
}
public int sizell
// Returns the number of elements in this queue.
{
return nymElements
}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1b2c1e36-9974-49eb-8a0c-fe4d3c635f06%2F00eca3c4-cf68-4b59-a001-910be4bfcb71%2F8pifi7_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 3 steps









