Declaration: Year 2010-2011, in Partial Fulfillment of The Requirements For The Award of POST GRADUATE
Declaration: Year 2010-2011, in Partial Fulfillment of The Requirements For The Award of POST GRADUATE
This work has not been undertaken or submitted elsewhere in connection with any
other academic course.
(ASHISH VYAS)
INTRODUCTION
This is Bus Reservation System Software made in C++, user can maintain current bus deployed
for reservation and the customers is reserving a seat in a particular valid bus with bus number.
This program is supposed to simulate a Reservation System of Bs. Using this program, Bus
ticket reservation agency assistant can perform different tasks related to ticket reservation.
The Bus Reservation System will ask the user for the following information :
• Name of passenger
• Departure City
• Destination City
• Date of travel
• Time of travel
• Number of tickets
The Bus Reservation System should have the following features:
1. Make Reservation-to reserve ticket/tickets for a passenger and indicate his/her seat number.
2. Modify reservation-to modify the already made reservation
3. Cancel reservation-to cancel a particular reservation
4. Search reservation- to search reservation information of a particular passenger by
a) Passenger name
b)Date of travel
5. Exit –to exit from application
Bus Reservation System should also support persistence for passenger ticket reservation records
Supporting simple persistence by any application requires handling of two scenarios
• On start up of application-data (passenger ticket reservation records) must be read from file.
• On end/finish up of application -data (passenger ticket reservation records) must be saved in
file
Software uses:-
1. Graphics library for graphics functions for menus, options display.
2. And other header files like conio.h, dos.h, stdio.h for controlling the flow of the program.
3. string.h for string manipulation functions.
4. And iostream.h for standard c++ syntaxes.
Software Structure:-
1. A class named as ‘a’.
2. Public Members :-
i. Methods are as follows:-
(i) void install(); // to a bus
(ii) void allotment();// to reserve a seat
(iii) void empty();// to empty a seat
(iv)void show();// to show bus seat information which is reserved or
empty
(v) void avail();// show available buses
(vi)void position(int i); // check whether there a empty seats or not
All methods are at public access area.
3. Private members :-
i. Data Members are as follows :-
(i) charbusn[5]. //character 1D array -> for bus no.
(ii) chardriver[10]. // character 1D array -> for driver name
(iii) chararrival[5]. // character 1D array -> for arrival time.
(iv)chardepart[5]. // character 1D array -> for departure time.
(v) charfrom[10]. // character 1D array -> for departure city name
(vi)charto[10]. // character 1D array -> for arrival city name
(vii) charseat[8][4][10]. // character 3D-array to maintain seat
information
Features:-
1. Add new buses
2. Reserve a seat for a particular customer for a particular bus.
3. Show the information about full bus seats with seat number and corresponding name of
passenger or ‘Empty’ if seat is not reserved.
4. Show buses available with driver name and departure and destination places with
estimated time of arrival and departure.
Source Code
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
#include <string.h>
#include <graphics.h>
#include <stdlib.h>
#include <dos.h>
staticint p = 0;
class a
{
char busn[5], driver[10], arrival[5], depart[5], from[10], to[10], seat[8][4][10];
public:
void install();
void allotment();
void empty();
void show();
void avail();
void position(int i);
}
bus[10];
voidvline(char ch)
{
for (int i=80;i>0;i--)
cout<<ch;
}
void a::install()
{
cout<<"Enter bus no: ";
cin>>bus[p].busn;
cout<<"\nEnter Driver's name: ";
cin>>bus[p].driver;
cout<<"\nArrival time: ";
cin>>bus[p].arrival;
cout<<"\nDeparture: ";
cin>>bus[p].depart;
cout<<"\nFrom: \t\t\t";
cin>>bus[p].from;
cout<<"\nTo: \t\t\t";
cin>>bus[p].to;
bus[p].empty();
p++;
}
void a::allotment()
{
int seat;
char number[5];
top:
cout<<"Bus no: ";
cin>>number;
int n;
for(n=0;n<=p;n++)
{
if(strcmp(bus[n].busn, number)==0)
break;
}
while(n<=p)
{
cout<<"\nSeat Number: ";
cin>>seat;
if(seat>32)
{
cout<<"\nThere are only 32 seats available in this bus.";
}
else
{
if (strcmp(bus[n].seat[seat/4][(seat%4)-1], "Empty")==0)
{
cout<<"Enter passanger's name: ";
cin>>bus[n].seat[seat/4][(seat%4)-1];
break;
}
else
cout<<"The seat no. is already reserved.\n";
}
}
if(n>p)
{
cout<<"Enter correct bus no.\n";
goto top;
}
}
void a::empty()
{
for(int i=0; i<8;i++)
{
for(int j=0;j<4;j++)
{
strcpy(bus[p].seat[i][j], "Empty");
}
}
}
void a::show()
{
int n;
char number[5];
cout<<"Enter bus no: ";
cin>>number;
for(n=0;n<=p;n++)
{
if(strcmp(bus[n].busn, number)==0)
break;
}
while(n<=p)
{
vline('*');
cout<<"Bus no: \t"<<bus[n].busn
<<"\nDriver: \t"<<bus[n].driver<<"\t\tArrival time: \t"
<<bus[n].arrival<<"\tDeparturetime:"<<bus[n].depart
<<"\nFrom: \t\t"<<bus[n].from<<"\t\tTo: \t\t"<<
bus[n].to<<"\n";
vline('*');
bus[0].position(n);
int a=1;
for (int i=0; i<8; i++)
{
for(int j=0;j<4;j++)
{
a++;
if(strcmp(bus[n].seat[i][j],"Empty")!=0)
cout<<"\nThe seat no "<<(a-1)<<" is reserved for "<<bus[n].seat[i]
[j]<<".";
}
}
break;
}
if(n>p)
cout<<"Enter correct bus no: ";
}
void a::position(int l)
{
int s=0;p=0;
for (int i =0; i<8;i++)
{
cout<<"\n";
for (int j = 0;j<4; j++)
{
s++;
if(strcmp(bus[l].seat[i][j], "Empty")==0)
{
cout.width(5);
cout.fill(' ');
cout<<s<<".";
cout.width(10);
cout.fill(' ');
cout<<bus[l].seat[i][j];
p++;
}
else
{
cout.width(5);
cout.fill(' ');
cout<<s<<".";
cout.width(10);
cout.fill(' ');
cout<<bus[l].seat[i][j];
}
}
}
cout<<"\n\nThere are "<<p<<" seats empty in Bus No: "<<bus[l].busn;
}
void a::avail()
{
for(int n=0;n<p;n++)
{
vline('*');
cout<<"Bus no: \t"<<bus[n].busn<<"\nDriver: \t"<<bus[n].driver
<<"\t\tArrival time: \t"<<bus[n].arrival<<"\tDeparture Time: \t"
<<bus[n].depart<<"\nFrom: \t\t"<<bus[n].from<<"\t\tTo: \t\t\t"
<<bus[n].to<<"\n";
vline('*');
vline('_');
}
}
void main()
{
clrscr();
int w;
intgd=DETECT, gm;
initgraph(&gd, &gm, "");
setbkcolor(BLUE);
while(1)
{
cout<<"\n\n\n\n\n";
cout<<"\t\t\t1.Install\n\t\t\t"
<<"2.Reservation\n\t\t\t"
<<"3.Show\n\t\t\t"
<<"4.Buses Available. \n\t\t\t"
<<"5.Exit";
cout<<"\n\t\t\tEnter your choice:-> ";
cin>>w;
switch(w)
{
case 1: bus[p].install();
break;
case 2: bus[p].allotment();
break;
case 3: bus[0].show();
break;
case 4: bus[0].avail();
break;
case 5: exit(0);
}
}
}
OUTPUT SCREENS