You are on page 1of 10

#include<iostream>

Using namespace std;


Typedef struct node
{
Char row_no;
Int seat_no,pin;
Char book;
Struct node *next,*prev;
}node;

Class dcll
{
Public:
Node *hn;
Dcll()
{
Hn=NULL;
}
Public:
Void create()
{
Node *nn,*cn;
Int j=1;

Volatile int k=2;


Char c =’A’;

Do
{
Int i=1;
Do
{
k=(k*k)/10+100-k/2;
nn=new node();
nn->next=nn->prev=NULL;
nn->row_no=c;
nn->seat_no=I;
nn->pin=k;
nn->book=’a’;
if(hn==NULL)
{
Hm=nn;
nn->next=nn->prev=hn;
}
Else
{
Cn=hn;

While(cn->next!=hn)
Cn=cn->next;
Cn->next=nn;
Nn->prev=cn;
nn->next=hn;
hn->prev=nn;
}
I++;
}while(i<=7);
J++;
C++;
}while(j<=10);
}

Void display()
{
Node *cn;
Cn=hn;
Cout<<”---------------------------------------------------------------------\n”;
Cout<<”| Platinum |\n”;
While(cn->next!=hn)
{
If((cn->prev)->row_no!=cn->row_no)
Cout<<”|”;
Cout<<cn->row_no;
Cout<<cn->seat_no;
If((cn->book==’a’)
Cout<<”->a”;//green text with black background
Else
Cout<<”->b”;//red text

If((cn->next)->row_no!=cn->row_no)
Cout<<”|\n”;
If(cn->row_no==’c’&&cn->seat_no==7)
{
Cout<<”-----------------------------------------------------------------------------------\n”;
Cout<<”| silver |\n”;
}
Cout=c->next;
}
Cout<<cn->row_no;
Cout<<cn->seat_no;
If(cn->book==’a’)
Cout<<”->a”; // green text with black background
Else
Cout<<”->b”; // red text
Cout<<”|\n”;
Cout<<”----------------------------------------------------------\n\n”;
Cout<<”platinum->150 gold ->100 silver ->60\n”;
}
Void display1(node *tmp [20],int n)
{
If(n!=1)
{
Cout<<”------------------------------------------------------------\n”;
Cout<<”thank you! \n you have successfully booked the seats\n”;
For(int i=1;i<n;i++)
Cout<<tmp[i]->row_no<<tmp[i]->seat_no<<”pin:”<<tmp[i]->pin<<”\n”;
08
Cout<<”!!!!!!!!!!!!!!!!!!!!!KEEP PIN SAFELY!!!!!!!!!!!!!!!!!!\n”;
Cout<<”PINS ARE REQUIRED AT THE THE TIME OF CANCELLATION OF SEATS\n”;
Cout<<”-----------------------------------------------------\n”;
}
}
Void book_seat()
{
Node*cn , *temp[20];
Int n,z,flag;
Char row;
Int seat;
Char ch;
do
{
z=1;
Cout<<”\n ENTER THE NO OF TICKETS YOU WANT TO BUY:”;
Cin>>n;
Cout<<”\n ENTER SEAT NUMBER(s):\n;
For(int i=1;i=<n;i++)
{
Cout<<”NO<<i<<”=”;
Cin>>row>>seat;
Cn=hn;
If(row>=’A’&&ro<=’E’)
{
While(cn->next!=hn)
{
If(cn->row_no==row&&cn->seat_no==seat)
{
If(cn->book==’a’)
{
Cn->book=’b’
Temp[z]=cn;
z++;
}
Else
{
Cout<<”INVALID CHOICE!\n”;
Cout<<cn->row_no<<”seat is already reserved\n”;
}
}
}
}
}
}
}
Display1(temp,z);
Cout<<”\n\n PRESS 1 TO CHECK SEAT STATUS\n”;
Cout<<”PRESS 2 TO BOOK OTHER SEAT\n”;
Cout<<”PRESS 3 TO EXIT BOOKING PORTAL\n”;
Cout<<”\ninput:”;
Cin>>ch;
If (ch==1)
Display();

}
While(ch==’2’);
}
Void cancel()
{
Char row,ch;
Int seat,pin;
Node *cn;
Cout<<”SEAT CANCELLATION\n”;
Do
{
Ch=’a’;
Cn=hn;
Cout<<”SEAT NUMBER:”;
Cin>>row>>seat:
Cout<<”PIN:”;
Cin>>pin;
If(row>=’A’&&row<=’E’)
{
While(cn->next!=hn)
{
If(cn->next!=hn)
{
If(cn->row_now==row&&cn->seat_no==seat&&cn->pin==pin)
{
Cout<<”Are you sure you want to cancel the seat(y/n)”;
Char c;

Cin>>c;
If(c==’y’||c==’y’)
{
Cout<<”SEAT CANCELLED SUCCESSFULLY!\n:”;
Cn->book=’a’
}
}
Else if(cn->row_no==row&&cn->seat_no==seat&&cn->pin!=pin)
{
Cout<<”invalid SEAT NUMBER&&PIN combination!\n;
}
Cn=cn->next;
}
}
Cout<<”\n\n Press 1to check status\n”;
Cout<<”Press 2 to cancel more tickets\n”;
Cout<<”Press 3 to exit cancellation portal\n”;
Cout<<’\ninput:”;
Cin>>ch;
If(ch==1)
Display();
}
While(ch==’2’);
}
};
Int main()
{

Dcll o;
Int ch;
Char c;
Cout<<”\n\n\n”;
Cout<<” @@@@@cinemax@@@@@\n”;
Cout<<” vvvvvv ARRANGEMENT vvvvv\n\n”;
o.create();
o.display();
do
{
Cout<<”\n\n\n”;
Cout<<”Press 1->BOOK TICKETS\n”;
Cout<<”Press 2->CANCEL TICKETS\n”;
Cout<<”Press 3->EXIT\n”;
Cout<<”\ninput”;
Cin>>ch;
Switch(ch)
{
Case 1:
o.book_seat();
o.dispaly();
break;
}
If(ch!=3)
{
Cout<<”Press 1 to main menu\n”;
Cout<<Press 2 to EXIT CINEMAX PORTAL\N;

Cout<<”\ninput”;
Cin>>c;
}
}
While(c==’1’);
Cout<<”\n\n\n”;
Return 0;

You might also like