
public class Queue {

	private int front=-1;
	private int rear = -1;
	private int array[];

	public Queue(int size) {
		array = new int[size];
	}

	public void print(){
		if(isEmpty())
			System.out.println("No Element !!");
		else{
			int i= rear+1;

			while(i!=front){
				System.out.println(array[i]);
			   i=(i+1)%array.length;
			}
			System.out.println(array[front]);

		}

	}

	public int getFront() {
		return front;
	}

	public int getRear() {
		return rear;
	}

	public boolean isEmpty(){
		return (front==-1) && (rear==-1);
	}

	public boolean isFull(){
		return (front==rear && front!=-1)||(rear==-1 && front==array.length-1);
	}

	public boolean enqueue(int data){
		if(isFull())
			return false;

		front = (front+1)% array.length;
		array[front]=data;
		return true;
	}

	public boolean dequeue(){
		if(isEmpty())
			return false;

		rear=(rear+1)% array.length;
		return true;
	}
}
