the very final bus project management system using c++
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<iomanip.h>
#include<dos.h>
#include<fstream.h>
#include<ctype.h>
#include<string.h>
#include<graphics.h>
//global functions
void startup();
//global variable
int j=0,c=0;
class danphetravel
{
private:
char name[50],from[30],add[80],to[30],month[10],flag;
float price;
int seatno,day;
double cellno;
int fare;
public:
int i;
void reserve();
void displayreservations();
void showtransportrec();
void deltransportrec();
void searchtransportrec();
void transfertransportdata();
void edittransportdata();
void transfertransportdata1();
void welcomescreen();
void sorryscreen();
void getonce()
{ clrscr();
cout<<"\n\n\n\Enter Total Seat of the Bus\n";
cin>>i;
cout<<"\n\n\n\nSet Bus Fare\n\n\n";
cin>>fare;
}
void decrease()
{
if(i>=j)
{
i=i-j;
c=1000;
}
else
{
c=i;
}
}
void increase()
{
i=i+j;
}
void recordfile();
}bookseat;
int main()
{
clrscr();
startup();
fstream fcheck;
bookseat.getonce();
fcheck.open("check.txt",ios::out);
fcheck.write((char*)&bookseat,sizeof(bookseat));
fcheck.close();
clrscr();
textbackground(YELLOW);
textcolor(RED);
//display main menu
int select;
do
{
cout<<"\t\t\t*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n";
cout<<"\t\t\t--<<D A N P H E_D E L U X E>>-- \n";
cout<<"\t\t\t*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n";
cout<<"\t\t\t W E L C O M E--T O--M A I N--M E N U \n\n\n";
cout<<"\t\t\t1. Make a Reservation\n";
cout<<"\t\t\t2. View Reservations\n";
cout<<"\t\t\t3. Edit a Reservation\n";
cout<<"\t\t\t4. Search for a Reservation\n";
cout<<"\t\t\t5. Delete a Reservation\n";
cout<<"\t\t\t6. Exit\n\n";
cout<<"\t\t\tSelect an option: ";
cin>>select;
switch(select)
{
case 1:
//funtion to reserve ticket
bookseat.recordfile();
break;
case 2:
//function to view ticket
bookseat.showtransportrec();
break;
case 3:
//function to edit ticket
bookseat.edittransportdata();
break;
case 4:
//function to search ticket
bookseat.searchtransportrec();
break;
case 5:
//function to delete ticket
bookseat.deltransportrec();
break;
default:
cout<<"Invalid Input.Try again!!";
break;
}
}
while(select!=6);
return 0;
}
//ticket is reserved here
void danphetravel::recordfile()
{
fstream file, f1;
file.open("transport.txt",ios::out |ios::app);
f1.open("check.txt", ios::in );
while(f1.read ((char*)&bookseat,sizeof (bookseat)))
{
if(bookseat.i!=0)
{
bookseat.reserve();
file.write((char*)&bookseat,sizeof (bookseat));
file.close();
}
else
{
clrscr();
sorryscreen();
}
f1.close();
}
}
//details taken from here to reserve ticket
void danphetravel::reserve()
{
clrscr();
flag='N';
while(flag!='Y')
{
clrscr();
welcomescreen();
clrscr();
textbackground(RED);
textcolor(BLUE);
gotoxy(25,5);cout<<"PLEASE FILL IN THE DETAILS PROPERLY...";
gotoxy(25,5);cout<<"DANPHE DELUXE TICKET RESERVATION FORM";
gotoxy(5,8);cout<<"Name: ";
gotoxy(5,10);cout<<"Address: ";
gotoxy(5,12);cout<<"From: ";
gotoxy(30,12);cout<<"To: ";
gotoxy(5,14);cout<<"No of Ticket:";
gotoxy(5,16);cout<<"Contact No:";
gotoxy(5,18);cout<<"Month:";
gotoxy(5,20);cout<<"Day:";
gotoxy(10,22);cout<<"Is the information correct(y/n)?? ";
gotoxy(10,8);gets(name);
gotoxy(13,10);gets(add);
gotoxy(19,12);gets(from);
gotoxy(40,12);gets(to);
gotoxy(20,14);cin>>seatno;j=seatno;
gotoxy(18,16);cin>>cellno;
gotoxy(18,18);gets(month);
gotoxy(18,20);cin>>day;
gotoxy(45,22);cin>>flag;
flag=toupper(flag);
}
bookseat.decrease();
if(c==1000)
{
fstream f2;
f2.open("check.txt", ios::out );
f2.write ((char*)&bookseat,sizeof (bookseat));
f2.close();
displayreservations();
}
else
sorryscreen();
}
void danphetravel::sorryscreen()
{
clrscr();
textbackground(GREEN);
textcolor(RED);
for(int k=13;k<17;k++)
{ clrscr();
gotoxy(k,10);cout<< ("ÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛ ÛÛÛÛÛÛ Û Û Û Û \n\n ");
gotoxy(k,11);cout <<("Û Û Û Û Û Û Û Û Û Û Û ");
gotoxy(k,12);cout <<("Û Û Û Û Û Û Û Û Û Û Û ");
gotoxy(k,13);cout <<("ÛÛÛÛÛÛÛÛÛ Û Û ÛÛÛÛÛÛ ÛÛÛÛÛÛ Û Û Û ");
gotoxy(k,14);cout <<(" Û Û Û ÛÛ ÛÛ Û Û Û ");
gotoxy(k,15);cout <<(" Û Û Û Û Û Û Û Û ");
gotoxy(k,16);cout <<("ÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛ Û Û Û Û Û Û Û ");
}
gotoxy(20,20);cout<<"There are only"<<" "<<c<<" "<<"SEATS available....";
getch();
}
void danphetravel::welcomescreen()
{
clrscr();
textbackground(GREEN);
textcolor(RED);
for(int k=13;k<17;k++)
{ clrscr();
gotoxy(k,10);cout<< ("Û Û ÛÛÛÛÛ Û ÛÛÛÛÛÛ ÛÛÛÛÛÛ Û Û ÛÛÛÛÛÛ \n\n ");
gotoxy(k,11);cout <<("Û Û Û Û Û Û Û ÛÛ ÛÛ Û ");
gotoxy(k,12);cout <<("Û Û Û ÛÛÛÛ Û Û Û Û Û Û Û ÛÛÛÛ ");
gotoxy(k,13);cout <<("Û Û Û Û Û Û Û Û Û Û Û ");
gotoxy(k,14);cout <<("ÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛ ÛÛÛÛÛÛ ÛÛÛÛÛÛ ÛÛÛÛÛÛ Û Û ÛÛÛÛÛÛ ");
}
gotoxy(20,20);cout<<"Press any key to start reservation....";
getch();
}
//it shows a ticket after sucessul reserved ticket
void danphetravel::displayreservations()
{
clrscr();
clrscr();
textbackground(YELLOW);
textcolor(RED);
gotoxy(25,5);cout<<"WELCOME TO DANPHE DELUXE TICKET RESERVATION ";
gotoxy(24,6);cout<<"----------------------------------------------";
gotoxy(15,8);cout<<"Name:"<<strupr(name);
gotoxy(15,10);cout<<"Address:"<<strupr(add);
gotoxy(15,12);cout<<"From: "<<from
<<" To:"<<to;
gotoxy(15,14);cout<<"No of Ticket:"<<seatno;
gotoxy(15,16);cout<<"Contact No:"<<cellno;
gotoxy(15,18);cout<<"Month:"<<month<<" Day:"<<day;
gotoxy(15,20);cout<<"Your Reservations have been done Please pay the Amount!!!";
gotoxy(25,22);cout<<"Please pay Amount: Rs."<<fare*seatno<<" To Complete Reservation";
getch();
}
//it shows all the reserved ticket
void danphetravel::showtransportrec()
{
fstream file1;
file1.open("transport.txt",ios::in);
while(file1.read((char*)&bookseat,sizeof (bookseat)))
bookseat.displayreservations();;
file1.close();
}
//ticket is deleted here using file temp 3
void danphetravel::deltransportrec()
{
clrscr();
textbackground(YELLOW);
textcolor(RED);
char delname[20];
gotoxy(20,5);cout<<"Enter name to delete record for...";
gotoxy(30,7);gets(delname);
clrscr();
strupr(delname);
fstream file2,file3;
int dele=0;
file2.open("transport.txt", ios::in);
file3.open("temp3.txt", ios::out );
while(file2.read ((char*)&bookseat,sizeof (bookseat)))
{
if ((strcmp(name,delname))!=0)
file3.write((char*)&bookseat,sizeof (bookseat));
else
j=bookseat.seatno;
dele++;
}
if(dele!=0)
{cout<<endl<<" ...Deleted...";
bookseat.increase();
fstream fcheck;
fcheck.open("check.txt", ios::out);
fcheck.write((char*)&bookseat,sizeof(bookseat));
fcheck.close();
}
else
cout<<endl<<" Record not found..";
getch();
file2.close();
file3.close();
transfertransportdata();
}
//function to delete records
void danphetravel::transfertransportdata()
{
fstream oldfile1,newfile1;
oldfile1.open("temp3.txt", ios::in);
newfile1.open("transport.txt", ios::out);
while(oldfile1.read((char*)&bookseat,sizeof(bookseat)))
newfile1.write((char*)&bookseat,sizeof (bookseat));
oldfile1.close();
newfile1.close();
}
void danphetravel::searchtransportrec()
{
clrscr();
textbackground(YELLOW);
textcolor(GREEN);
char sename[20];
gotoxy(20,5);cout<<"Enter Name to search for..";
gotoxy(25,7);gets(sename);
strupr(sename);
fstream file4;
file4.open("transport.txt", ios::in);
int serch=0;
while(file4.read((char*)&bookseat,sizeof (bookseat)))
{
if(strcmp(name,sename)==0)
{
serch++;
bookseat.displayreservations();;
}
}
if(serch==0)
cout<<" No Record Exists";
file4.close();
getch();
}
//using file temp2 record is edited here
void danphetravel::edittransportdata()
{
clrscr();
textbackground(BLUE);
textcolor(RED);
char edname[30];
int ede1=0;
gotoxy(20,5);cout<<"Enter Name to Edit Record for...";
gotoxy(25,7);gets(edname);
strupr(edname);
fstream file5,file6;
file5.open("transport.txt", ios::in) ;
file6.open("temp2.txt", ios::out ) ;
while(file5.read((char*)&bookseat,sizeof(bookseat)))
{
if (strcmp (edname,name)==0)
{
reserve();
ede1++;
}
file6.write((char*)&bookseat,sizeof (bookseat));
}
if(ede1==0)
{
gotoxy(25,17);cout<<"RECORD DOESNT EXIST!!!!";
}
getch();
file5.close();
file6.close();
transfertransportdata1();
}
//function to edit records
void danphetravel::transfertransportdata1()
{
fstream oldfile3,newfile3;
oldfile3.open("temp2.txt", ios::in);
newfile3.open("transport.txt",ios::out);
while(oldfile3.read((char*)&bookseat,sizeof(bookseat)))
newfile3.write((char*)&bookseat,sizeof (bookseat));
oldfile3.close();
newfile3.close();
}
//function to display start screen
void startup()
{
clrscr();
textbackground(YELLOW);
textcolor(RED);
for(int j=0;j<10;j++)
{
clrscr();
gotoxy(j,6); cputs(" ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ");
gotoxy(j,7); cputs(" ÜÜÜÜÜÜÜ ÜÜÜÜÜÜ ÜÜÜÜÜÜ");
gotoxy(j,8); cputs(" Û Û Û Û Û");
gotoxy(j,9); cputs(" Û ÛÜÜÜÛ ÛÜÜÜÜÛ");
gotoxy(j,10);cputs(" Û Û Û Û Û");
gotoxy(j,11);cputs(" Û Û ÛÛ Û Û");
gotoxy(51-j,6); cputs("ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ \n\r");
gotoxy(51-j,7); cputs(" Ü Ü ÜÜÜÜÜÜ Ü \n\r");
gotoxy(51-j,8); cputs(" Û Û Û Û \n\r");
gotoxy(51-j,9); cputs(" Û Û ÛÜÜÜ Û \n\r");
gotoxy(51-j,10);cputs(" Û Û Û Û \n\r");
gotoxy(51-j,11);cputs(" ÛÛ ÛÛÛÛÛÛ ÛÛÛÛ \n\r\n\n");
gotoxy(j,12);cputs(" Ü Ü ÜÜÜÜÜÜ ");
gotoxy(j,13);cputs(" ÛÛ Û Û ");
gotoxy(j,14);cputs(" Û Û Û ÛÛÛÛ ");
gotoxy(j,15);cputs(" Û Û Û Û ");
gotoxy(j,16);cputs(" Û ÛÛ ÛÛÛÛÛÛÛ ");
gotoxy(j,17);cputs(" ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\n\n");
gotoxy(58-j,12);cputs(" ÜÜÜÜÜÜ ÜÜÜÜÜÜ Ü \n\r");
gotoxy(58-j,13);cputs(" Û Û Û Û Û \n\r");
gotoxy(58-j,14);cputs(" ÛÛÛÛÛÛ ÛÜÜÜÜÛ Û \n\r");
gotoxy(58-j,15);cputs(" Û Û Û Û \n\r");
gotoxy(58-j,16);cputs(" Û Û Û ÛÛÛÛÛÛÛÛÛ \n\r");
gotoxy(58-j,17);cputs("ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ \n\r");
}
gotoxy(25,25);
cout<<"press any key to continue...";
getch();
}
Great insights on project management for bus systems! If you're looking for an efficient online ticketing system, check out CW Ticketing System. It simplifies ticket booking and management for various transportation modes.
ReplyDeleteThis is the website https://www.cwticketingsystem.com/