OOP Report 2133 2134
OOP Report 2133 2134
Micro Project
OBJECTIVE:
The main objective is to make bus reservation easier. This will reduce time.
Description of project:
❖ If-else: Used to check a particular condition
❖ While, for loop: Execute some piece of code number of times.
❖ Switch: Select option and execute code regarding to selected option.
ADVANTAGE:
Helps to understand the working of a bigger program and able to solve and
understand the complex program.
Project Coding:
#include <stdio.h>
#include<conio.h>
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include<dos.h>
static int 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];
void vline(char ch)
{
for (int i=80;i>0;i--)
cout<<ch;
}
void a::install()
{
clrscr();
cout<<"Enter bus no: ";
cin>>bus[p].busn;
cin>>bus[p].driver;
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++;
clrscr();
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<< "Your Booking Processing....Please wait....";
delay(2500);
clrscr();
}
void a::allotment()
{
clrscr();
int seat;
char number[5];
top:
cin>>number;
int n;
for(n=0;n<=p;n++)
if(strcmp(bus[n].busn, number)==0)
break;
}
while(n<=p)
{
cin>>seat;
if(seat>32)
else
if (strcmp(bus[n].seat[seat/4][(seat%4)-1], "Empty")==0)
cin>>bus[n].seat[seat/4][(seat%4)-1];
break;
else
if(n>p)
{
goto top;
}
delay(2000);
clrscr();
void a::empty()
{
clrscr();
for(int j=0;j<4;j++)
strcpy(bus[p].seat[i][j], "Empty");
}
delay(2000);
clrscr();
}
void a::show()
{
clrscr();
int n;
char number[5];
cin>>number;
for(n=0;n<=p;n++)
if(strcmp(bus[n].busn, number)==0)
break;
while(n<=p)
vline('*');
<<bus[n].arrival<<"\tDeparture time:"<<bus[n].depart
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)
break;
if(n>p)
void a::position(int l)
{
clrscr();
int s=0;p=0;
{
cout<<"\n";
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];
void a::avail()
{
clrscr();
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
/*cout<<" Buses are not available during Covid-19."; */
for(int n=0;n<p;n++)
//vline('*');
cout<<" Bus- "<<n+1<<endl;
vline('*');
<<bus[n].to<<"\n";
vline('*');
vline('_');
}
delay(9600);
clrscr();
}
void main()
system("cls");
int w;
while(1)
//system("cls");
cout<<"\n";
vline('*');
cout<<"\n";
cout<<"\t\t\t1.Install\n\t\t\t"
<<"2.Reservation\n\t\t\t"
<<"3.Show\n\t\t\t"
<<"5.Exit";
cin>>w;
cout<<"\n\n\n\n";
vline('*');
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);
}
// vline('*');
getch();
Program Output:
Conclusion:
Bus reservation system is very helpful for those people who use buses for travelling so it is
important to save their time from buying the tickets. This program helps them to reserve
the seats fast. This program also shows which buses are available and what is its arriving
and departure time. By knowing the time people can manage their time.