I'm trying to make an array-based queue that inserts and removes the elements...
The default array is {0,0,0,9,10}. after the 0's are filled up it should say that its Full and will return to the loop. I'm having trouble making 3 particular methods which is dequeue, isEmpty, and isFull..
class QueueMethods{
public int[]array;
public int front, rear, maxSize, nItems, temp;
public QueueMethods(int s)
{
maxSize = s;
array = new int[maxSize];
front = 0;
rear = -1;
nItems = 0;
}
public int[] display()
{
for(int x=0; x<5;x++)
{
System.out.print("["+array[x]+"]" + " ");
}
return array;
}
public boolean isEmpty()
{
System.out.println("The queue is Empty, you can either enqueue or exit the program");
//codes
}
public boolean isFull()
{
System.out.println("The queue is already full, you can either dequeue or exit the program");
//codes
}
public void enqueue(int o)
{
if(rear == maxSize -1)
rear = -1;
array[++rear]=o;
nItems++;
}
public int dequeue()
{
//codes
}
}
pls help, thx in advance