#include <iostream>
using namespace std;

class Queue{
private:
int front;
int rear;
int arr[5];
public:
Queue(){
front=-1;
rear=-1;
for(int i=0;i< 5;i++){
arr[i]=0;
}
}
bool isempty(){
if(front==-1 && rear==-1) return true;
else return false;
}
bool isFull(){
if(rear==4) return true;//rear value = array size
else return false;
}
void enqueue(int value){
if(isFull()){
cout<<"Queue is Full"<<endl;
return;
}
else if(isempty()){
front=0;
rear=0;
arr[rear]=value;
}
else{
rear++;
arr[rear]=value;
}
}
int dequeue(){
int temp;
if(isempty()){
cout<<"Queue is empty"<<endl;
return 0;
}
else if(front==rear){
temp=arr[front];
arr[front]=0;
front=rear=-1;
return temp;
}
else{
temp=arr[front];
arr[front]=0;
front++;
return temp;
}
}
int count(){
return(rear-front+1);
}
void display(){
cout<<"All values in the Queue are: "<<endl;
for(int i=0;i< 5;i++){
cout<<arr[i]<<" ";
}
}
};
int main(){
Queue q;
int option, value;
do {
cout<<"What operation would you like to perform?"<<endl;
cout<<"1.Enqueue()"<<endl;
cout<<"2.Dequeue()"<<endl;
cout<<"3.isEmpty()"<<endl;
cout<<"4.isFull()"<<endl;
cout<<"5.count()"<<endl;
cout<<"6.display()"<<endl;
cout<<"7.clear screen"<<endl;
cout<<"Enter your choice (enter 0 for exit)"<<endl;
cin>>option;
switch (option) {
case 0:
cout<<"Exit"<<endl;
break;
case 1:
cout<<"Enqueue Operations"<<endl;;
cout<<"Enter the value:";
cin>>value;
q.enqueue(value);
break;
case 2:
cout<<"Dequeued operation\n Dequeued value: "<<q.dequeue()<<endl;
break;
case 3:
if (q.isempty())
cout<<"Queue is empty."<<endl;
else
cout<<"Queue is not empty"<<endl;
break;
case 4:
if(q.isFull())
cout<<"Queue is full"<<endl;
else
cout<<"Queue is not full"<<endl;
break;
case 5:
cout<<"Count Operations\n Number of elements in the queue: "<<q.count()<<endl;
break;
case 6:
cout<<"Queue items: ";
q.display();
break;
default:
cout<<"Invalid option! Please try again."<<endl;
}
}
while (option!=0);
return 0;
}