Вы находитесь на странице: 1из 3

#include<iostream>

using namespace std;


#define m 8
class ticket
{
private:
int q[m];
int front;
int rear;
protected:
bool isempty()
{
return (front == 0 && rear == 0);
}
bool isfull()
{
return(front == 0 && rear == m - 1 || front == rear + 1);
}
public:
ticket()
{
front = rear = 0;
}
void enqueue(int w)
{
if (!isfull())
{
if (front != 0 && rear == m)
rear = 0;
rear++;
q[rear] = w;
if (front == 0)
{
front = 1;
}
cout << "Congrats Your Request for " << w << " Tickets are gone
for Approval" << endl;

}
else if (isfull())
{
cout << "All Tickets Are Reserved" << endl;
}
}
void dequeue()
{
if (!isempty())
{
int a;
a = q[front];
if (a <= 2)
{
cout << "Your " << a << " Tickets Are Approved" << endl;
}
else
{
cout << "Sorry Only two tickets are allowed at one time\nIf
You want to approve the " << a - 2 << " More Tickets then Apply Again" << endl;
}
front++;
}
}
void show()
{

}
};
int main()
{
ticket T;
int y;
int c;
start:
system("cls");
cout << "\t\t\t---------------------WelCome in TICKET
WINDOW---------------------" << endl;
cout << endl;
cout << "\t\t\t\t'1' For Enter TICKETS" << endl;
cout << "\t\t\t\t'2' For Check Your Booking Status" << endl;
cin >> c;
system("cls");
switch (c)
{
case 1:
{
e:
system("cls");
cout << "Enter The Tickets : ";
cin >> y;
T.enqueue(y);
char i;
cout << "If You Want to Enter the Tickets Again then Press Y :";
cin >> i;
if (i == 'Y')
{
goto e;
}
else
{
goto start;
}

}
break;
case 2:
{
system("cls");
T.dequeue();
cout << endl;
char i;
cout << "If You Want to Go Back In mAin MeNu then Press Y :";
cin >> i;
if (i == 'Y')
{
goto start;
}
else
{
goto exist;
}
}
break;
default:
cout << "Exit" << endl;
}
goto start;
cout << endl;
exist:
system("pause");
}

Вам также может понравиться