0% found this document useful (0 votes)
43 views10 pages

Practical No.8

Uploaded by

Paras Kamble
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views10 pages

Practical No.8

Uploaded by

Paras Kamble
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Practical No: 08 (Group C)

Name: Swapnil ManishKamble


Paras Chandan Suryavanshi
Class: SE
Div : C
Batch: C3
Roll No: SS213085
213074

Problem Statement:
Statement:-- The
The ticket
ticket booking system of Cinemax theater has to be
implemented using C++ program. There are 10 rows and 7 seats in each row.
Doubly circular linked list has to be maintained to keep track of free seats at rows.
Assume some random booking to start with. Use array to store pointers (Head
pointer) to each row. On demand
a) The list of available seats is to be displayed
b) The seats are to be booked
c) The booking can be cancelled.
Code:
Code:
#include <iostream>
#include<stdlib.h>
using namespace std;
class node { public:
node* next;
node* prev;
int seat;
string id; int
status; class
cinemax

public:
node* head, * tail , * temp; cinemax()

head=NULL;

void create_list();

void display();
void book();
void cancel();
void avail();

void cinemax::create_list() { int i=l; temp=new node; temp->seat=l;


temp->status=O; tail=head=temp; for(int i=2;i<=70;i++)

node *p; p=
new node; p-
>seat=i; p-
>status=O;

tail->next=p; p->prev=tail; tail=p;


tail->next=head; head-
>prev=tail; void
cinemax::display()

{ int r=l;
node* temp;
temp=head;
int count=O;

n"; cout<<" Screen this way


\n";

while(temp->next!=head)

if(temp->seat/10==O)

else cout<<"S"<<temp-
>seat<<" if(temp-
>status==O)

else

count++;
if(count%7==O)

cout<<endl; temp=temp->next; if(temp-

>status==O)

else
void cinemax::book()
{ int x;
string y;
label:
cout<<"\n\n\nEnter seat number to be booked\n";
cin>>x; cout<<"Enter your ID number\n"; cin>>y;

cout<<"Enter correct seat number to book (1-70)\n"; goto label;

node *temp;
temp=new node;
temp=head;
while(temp->seat!=x)

temp=temp->next;

if(temp->status==l)
cout<<"Seat already booked
; else{ temp->status=l;

temp->id=y; cout<<"Seat
booked!\n";
void cinemax::cancel()

int x;
string
y;
labell:
cout<<"Enter seat number to cancel booking\n"; cin>>x;

cout<<"Enter you ID\n";


cin>>y;

cout<<"Enter correct seat number to cancel (1-70)\n"; goto labell;

node *temp;
temp=new node;
temp=head;
while(temp->seat!=x)

temp=temp->next;

if(temp->status==O)
cout<<"Seat not booked yet!!\n , else

if(temp->id==y)

temp->status=O; cout<<"Seat Cancelled!\n"; } else


cout<<"Wrong User ID !!! Seat cannot be cancelled!! !\n";
void cinemax::avail()

int r=l;
node* temp;

temp=head; int
count=O;
cout<<"\n\n\n\n"
;

n"; cout<<" Screen this way


\n";

\n"; while(temp-
>next!=head) if(temp-
>seat/10==O)

else cout<<"S"<<temp->seat<<" if(temp-


>status==O)

else if(temp->status==l) cout<<


count++; if(count%7==O)

cout<<endl;
temp=temp->next;

if(temp->status==O)

if(temp->status==O)

int main() {
cinemax obj;
obj.create_list()
; int ch; char
c='y';

{ obj.display(); cout<< \n

CINEMAX MOVIE THEATRE\n"; cout<<

cout<<"\nEnter Choice\n1.Current SeatStatus\n2.Book Seat \n3.Available

Seat\n4.CancelSeat\n"
; cin>>ch; switch(ch)

case l:obj.display();
break; case 2:
obj.book(); break;
case 3:obj.avail();
break; case 4:
obj.cancel(); break;
default: choice input\n";

cout<<"\nDo you want to perform any other operation : (y/n)\n"; cin>>c;

return O;

Output:

You might also like