Documente Academic
Documente Profesional
Documente Cultură
=============
//
//
//
RAILWAY
MANAGEMENT SYSTEM
//
//
//==============================================================
=============
#include <iostream.h>
#include <conio.h>
#include <dos.h>
#include <string.h>
#include <fstream.h>
#include <process.h>
#include <stdio.h>
//==============================================================
=============
//
// =>
CLASS: railway
// => OBJECTIVE: contains most of the functions
//
of the project.
//
//==============================================================
=============
class railway
{
char train[20],link[30],time[20];
float reser,seats,compart,trainno,platform;
public:
void choice();
void getdata()
{
textcolor(CYAN);
textbackground(BLUE);
clrscr();
cout<<"\n\n\n\t\t\t%%%%%% RAILWAY DEPARTMENT %%%%%
%";
gotoxy(27,44);
cout<<"Thanks for using our service.";
gotoxy(18,48);
gotoxy(68,c-3);
cout<<seats;
}
char* gettrain()
{
return train;
}
char* getlink()
{
return link;
}
char* gettime()
{
return time;
}
float gettno()
{
return trainno;
}
float platforms()
{
return platform;
}
//==============================================================
=============
//
//
= FUNCTION NAME: showdata2
//
=
OBJECTIVE: This function return the
//
information for platform
//
table.
//
//==============================================================
=============
void showdata2(int c)
{
gotoxy(27,44);
cout<<"Thanks for using our service.";
gotoxy(18,48);
cout<<"##### Give us chance to serve you again.#####";
gotoxy(3,c-1);
cout<<platform;
gotoxy(13,c-1);
puts(train);
gotoxy(30,c-1);
puts(time);
}
};
//==============================================================
=============
//
//
=>
CLASS: MENU
//
=>
OBJECTIVE: It gives a bold look
//
to the programmme.
//
//==============================================================
=============
class menu
{
public :
void start(void) ;
main_menu(void);
};
class lines
{
public :
void line_hor (int, int, int, char) ;
void line_ver (int, int, int, char) ;
void box (int,int,int,int,char) ;
};
void lines :: line_hor(int column1, int column2, int row, char c)
{
for ( column1; column1<=column2; column1++ )
{
gotoxy(column1,row) ;
cout <<c ;
}
}
row2-- ;
line_ver(row1,row2,column1,l2) ;
line_ver(row1,row2,column2,l2) ;
}
//==============================================================
=============
//
//
=>
FUNCTION: START
//
=>
OBJECTIVE: This function is to
//
show credits.
//
//==============================================================
=============
void menu :: start()
{
lines line ;
clrscr() ;
textmode(C40);
textbackground(BLACK);
textcolor(RED) ;
clrscr() ;
gotoxy(8,7) ;
cout <<"RAILWAY MANAGEMENT SYSTEM" ;
line.box(4,10,36,4,219) ;
gotoxy(5,13);
cout<<"PROJECT COORDINATOR:";
gotoxy(5,21);
cout<<"MADE BY :";
gotoxy(20,17);
cout<<"Mrs. Neena Sharma";
gotoxy(20,19);
cout<<"(HOD-CS)";
gotoxy(20,21);
cout<<"1.Saurabh and Shubham";
line.box(2,19,40,24,219);
gotoxy(4,10);
getch() ;
textbackground(BLACK) ;
textcolor(LIGHTGRAY) ;
clrscr() ;
}
//==============================================================
=============
//
// => FUNCTION NAME: write file.
// =>
OBJECTIVE: store the information given by the
//
user in binary file.
//
//==============================================================
=============
void writefile()
{
clrscr();
ofstream fout;
railway t;
int n,i;
char ch='y';
fout.open("railway.dat",ios::binary|ios::app);
cout<<"\n\n\n\t\t\t%%%%%% RAILWAY DEPARTMENT %%%%%%\n";
gotoxy(27,44);
cout<<"Thanks for using our service.";
gotoxy(18,48);
cout<<"##### Give us chance to serve you again.#####";
gotoxy(5,6);
cout<<"\n\n\n\tHow many trains you want to enter:";
cin>>n;
for(i=0;i<n;i++)
{
t.getdata();
fout.write((char*)&t,sizeof(t));
}
clrscr();
cout<<"\n\n\n\n\n\n\n\tWant to enter MORE records?(y/n)...";
cin>>ch;
if(ch=='y')
{
cout<<"\tHow many record U want to enter: ";
cin>>n;
for(i=0;i<n;i++)
{
t.getdata();
fout.write((char*)&t,sizeof(t));
}
}
else
fout.close();
}
//==============================================================
=============
//
// =>
FUNCTION NAME: view data.
// =>
OBJECTIVE: this function shows all the data of the
//
table in train inquiry of main menu.
//
//==============================================================
=============
void viewdata()
{
fstream fin;
railway t;
int c=14;
fin.open("railway.dat",ios::binary|ios::in);
if(fin==NULL)
{
cout<<"File opening error.";
exit(0);
}
fin.read((char*)&t,sizeof(t));
while(!fin.eof())
{
t.showdata(c=c+3);
fin.read((char*)&t,sizeof(t));
delay(500);
}
fin.close();
}
//==============================================================
=============
//
//
=>
FUNCTION NAME: MODIFY
//
=>
OBJECTIVE: it allows user to change the
//
information in modify table of
//
train inquiry.
//
//==============================================================
=============
void modify()
{
fstream fin;
railway t;
int rec=0,tno;
fin.open("railway.dat",ios::binary|ios::in|ios::out);
if(fin==NULL)
{
cout<<"File opening error:";
exit(0);
} clrscr();
cout<<"\n\n\n\t\t\t%%%%%% RAILWAY DEPARTMENT %%%%%%";
gotoxy(27,44);
cout<<"Thanks for using our service.";
gotoxy(18,48);
cout<<"##### Give us chance to serve you again.#####";
gotoxy(5,6);
cout<<"\n\n\tEnter train number which needs to be changed:";
cin>>tno;
fin.read((char*)&t,sizeof(t));
while(!fin.eof())
{
if(tno==t.gettno())
{
fin.seekp(rec*sizeof(t),ios::beg);
t.getdata();
fin.write((char*)&t,sizeof(t));
break;
}
else
{
textbackground(WHITE);
textcolor(BLUE);
clrscr();
gotoxy(25,15);
cout<<"Train number NOT found";
fin.read((char*)&t,sizeof(t));
rec++;
}
}
fin.close();
}
//==============================================================
=============
//
//
=>
FUNCTION NAME: REMOVE
//
=>
OBJECTIVE: This function is delete the
//
particular selected train
//
information.
//
//==============================================================
=============
void remove()
{
clrscr();
fstream fin,fout;
railway s;
char ch;
int no;
fin.open("railway.dat",ios::in|ios::binary);
if(fin==NULL)
{
cout<<"file opening error";
exit(0);
}
fout.open("temp.dat",ios::out|ios::binary);
cout<<"\n\n\n\t\t\t%%%%%% RAILWAY DEPARTMENT %%%%%%";
gotoxy(27,44);
cout<<"Thanks for using our service.";
gotoxy(13,10);
cout<<"Enter train number which you want to delete\n\n\n";
gotoxy(13,14);
cin>>no;
gotoxy(13,17);
cout<<"Are you sure.(y/n): ";
cin>>ch;
if(ch=='y')
{
fin.read((char*)&s,sizeof(s));
while(!fin.eof())
{
if(no!=s.gettno())
{
fout.write((char*)&s,sizeof(s));
}
fin.read((char*)&s, sizeof(s));
}
fin.close();
fout.close();
fin.open("temp.dat",ios::in|ios::binary);
fout.open("railway.dat",ios::out|ios::binary);
fin.read((char*)&s,sizeof(s));
while(!fin.eof())
{
fout.write((char*)&s,sizeof(s));
fin.read((char*)&s,sizeof(s));
}
}
else
s.choice();
fin.close();
fout.close();
}
//==============================================================
=============
//
//
FUNCTION NAME: viewdata2
//
OBJECTIVE: It is used to view the
//
content of platform
//
table.
//
//==============================================================
=============
void viewdata2()
{
fstream fin;
railway t;
int c=14;
fin.open("railway.dat",ios::binary|ios::in);
if(fin==NULL)
{
cout<<"File opening error.";
exit(0);
}
fin.read((char*)&t,sizeof(t));
while(!fin.eof())
{
t.showdata2(c=c+3);
fin.read((char*)&t,sizeof(t));
delay(500);
}
fin.close();
}
//==============================================================
=============
//
//
=>FUNCTION NAME: TABLE.
//
=> OBJECTIVE: this is a special funtion which
//
shows table in train inquiry and
//
reservation inquiry.
//
//==============================================================
=============
void table()
{
textcolor(RED);
clrscr();
cout<<"\n\n\n\t\t\t%%%%%% RAILWAY DEPARTMENT %%%%%
%";
gotoxy(1,12);
cout<<"_________________________________________________________________
__________";
gotoxy(1,9);
cout<<"_________________________________________________________________
__________";
gotoxy(1,39);
cout<<"_________________________________________________________________
__________";
gotoxy(27,44);
cout<<"Thanks for using our service.";
gotoxy(18,48);
cout<<"##### Give us a chance to serve you again.#####";
gotoxy(4,11);
textcolor(RED);
cout<<"TRAIN NO.";
for(int i=9;i<39;i++)
{
gotoxy(2,i);
cout<<"\n"<<"|";
}
for(int j=10;j<40;++j)
{
gotoxy(12,j);
cout<<"|";
}
gotoxy(18,11);
cout<<"TRAIN NAME";
for(int k=10;k<40;k++)
{
gotoxy(32,k);
cout<<"|";
}
gotoxy(40,11);
cout<<"LINK";
for(int l=10;l<40;l++)
{
gotoxy(52,l);
cout<<"|";
}
gotoxy(57,11);
cout<<"TIME";
for(int m=10;m<40;++m)
{
gotoxy(65,m);
cout<<"|";
}
gotoxy(68,11);
cout<<"SEATS";
for(int n=10;n<40;n++)
{
gotoxy(75,n);
cout<<"|";
}
}
//==============================================================
=============
//
//
=> FUNCTION NAME: color.
//
=> OBJECTIVE: it gives special colors in the
//
output screen.
//
//==============================================================
=============
//==============================================================
=============
//
=> FUNCTION NAME: reser.
//
=> OBJECTIVE: this function will write the
//
reservation information in
//
binary file.
//
//==============================================================
=============
void reser()
{
clrscr();
double pnr=4136110,b,c;
railway t;
char link[20],name[20];
cout<<"\n\n\n\t\t\t%%%%%% RAILWAY DEPARTMENT %%%%%%";
gotoxy(27,44);
cout<<"Thanks for using our service.";
gotoxy(18,48);
cout<<"##### Give us chance to serve you again.#####";
gotoxy(7,8);
cout<<"\n\n\n\t** Choose link iformation from'train inquiry' under MAIN MENU
**\n\t";
gotoxy(4,13);
cout<<"\t-----------------------------------------------------------";
cout<<"\n\n\n\tFeed the name of the train for which you want reservation:";
gets(name);
if((strcmp(name,t.gettrain())==0))
{
cout<<"\n\n\t\tYour PNR number is:"<<pnr;
getch();
}
else
{
cout<<"\n\n\t\t Wrong Information.";
}
getch();
}
//==============================================================
=============
//
//
=> FUNCTION NAME: cost.
//
=> OBJECTIVE: this function tells the charges for
//
the ticket as well as reservation
//
charges.
//
//==============================================================
=============
void cost()
{
clrscr();
char compart;
char ac;
do
{
textcolor(RED);
textbackground(CYAN);
clrscr();
cout<<"\n\n\n
%%%%%% RAILWAY DEPARTMENT %%
%%%%\n ";
gotoxy(27,46);
cout<<"Thanks for using our service.";
gotoxy(18,48);
cout<<"##### Give us chance to serve you again.#####";
gotoxy(7,7);
cout<<"Select the option:";
gotoxy(7,10);
cout<<"*********************************************";
for(int i=11;i<22;i++)
{
gotoxy(7,i);
cout<<"*";
}
gotoxy(8,21);
cout<<"********************************************";
for(int j=11;j<22;j++)
{
gotoxy(51,j);
cout<<"*";
}
gotoxy(13,13);
{
case 'A':
cout<<"\n\n\n\n\n\n\n\n\tCharges are
Rs.600."; getch();
break;
case 'a':
cout<<"\n\n\n\n\n\n\n\n\tCharges are
Rs.600."; getch();
break;
case 'B':
cout<<"\n\n\n\n\n\n\n\n\tCharges are
Rs.500."; getch();
break;
case 'b':
cout<<"\n\n\n\n\n\n\n\n\tCharges are
Rs.500."; getch();
break;
case 'C':
cout<<"\n\n\n\n\n\n\n\n\tCharges are
Rs.400.\n\t"; getch();
break;
case 'c':
cout<<"\n\n\n\n\n\n\n\n\tCharges are
Rs.400.\n\t";
getch();
break;
default:
cout<<"\n\n\n\n\n\n\n\n\t!!!!! Invalid choice
!!!!!\a";
}
}
}while(compart!='4');
}
//==============================================================
=============
//
//
FUNCTION NAME: platform
//
OBJECTIVE: It is used to frame
//
structure of platform
//
table.
//
//==============================================================
=============
void platform()
{
textcolor(MAGENTA);
textbackground(BLACK+WHITE);
clrscr();
cout<<"\n\n\n\t\t\t%%%%%% RAILWAY DEPARTMENT %%%%%%";
gotoxy(27,44);
cout<<"Thanks for using our service.";
gotoxy(1,14);
cout<<"______________________________________
______________________________________";
gotoxy(1,9);
cout<<"______________________________________
______________________________________";
gotoxy(1,39);
cout<<"\n\n______________________________________
______________________________________";
gotoxy(18,48);
cout<<"##### Give us a chance to serve you again.#####";
gotoxy(2,11);
textcolor(RED);
cout<<"PLATFORM\n\n NO.";
for(int i=9;i<41;i++)
{
gotoxy(2,i);
cout<<"\n"<<"|";
}
for(int j=10;j<42;++j)
{
gotoxy(10,j);
cout<<"|";
}
gotoxy(15,11);
cout<<"TRAIN NAME";
for(int k=10;k<42;k++)
{
gotoxy(28,k);
cout<<"|";
}
gotoxy(31,11);
cout<<"TIME";
for(int l=10;l<42;l++)
{
gotoxy(38,l);
cout<<"|";
}
gotoxy(44,11);
cout<<"PLATFORM";
gotoxy(47,13);
cout<<"NO.";
for(int m=10;m<42;++m)
{
gotoxy(43,m);
cout<<"|";
}
gotoxy(57,11);
cout<<"TRAIN NAME";
for(int n=10;n<42;n++)
{
gotoxy(52,n);
cout<<"|";
}
gotoxy(72,11);
cout<<" TIME";
for(int o=10;o<42;o++)
{
gotoxy(71,o);
cout<<"|";
}
for(int p=10;p<42;p++)
{
gotoxy(80,p);
cout<<"|";
}
for(int q=10;q<42;q++)
{
gotoxy(41,q);
cout<<"";
}
}
//==============================================================
=============
//
//
=> FUNCTION NAME: password.
//
=> OBJECTIVE: this function adds the special features
//
to this software.This function restrict
//
the costumers to access modification
//
area of railway department.Due to this
//
speciality railway domain controllers
//
can access this field by adding the
//
password 'railway'.
//
//==============================================================
=============
void password()
{
clrscr();
char a[20];
railway t;
int i=0;
gotoxy(32,5);
cout<<"ENTER THE PASSWORD \n";
gotoxy(30,7);
cout<<"#####################";
gotoxy(30,11);
cout<<"#####################";
for(int j=7;j<11;j++)
{
gotoxy(30,j);
cout<<"*";
}
for(int s=7;s<11;s++)
{
gotoxy(50,s);
cout<<"*";
}
gotoxy(32,9);
do
{
a[i]=getch();
cout<<"*";
if(a[i]==8)
{
cout<<"\b";
}
if(a[i]==13)
{
a[i]='\0';
break;
}
else
{
i++;
}
}while(a[i-1]!=13);
cout<<a<<endl;
if((strcmp(a,"railway")==0)|(strcmp(a,"RAILWAY")==0))
{
gotoxy(16,17);
cout<<"\n\n\n\n\n\t\t\t===================";
cout<<"\n\n\n\n\n\n\n\t\t\t CORRECT PASSWORD ";
cout<<"\n\n\n\n\n\n\t\t\t===================";
}
else
{
gotoxy(33,23);
cout<<"WRONG PASSWORD";
getch();
exit(0);
}
}
//==============================================================
=============
//
//
=> FUNCTION NAME: choice.
//
=> OBJECTIVE: this function allows the user to
//
enter a particular choice.
//
//==============================================================
=============
void railway::choice()
{
char no;
do
{ textcolor(GREEN);
textbackground(BLACK);
clrscr();
cout<<"\n\n\n
%%%%%% RAILWAY DEPARTMENT %%%%%%\n
";
gotoxy(18,48);
cout<<"##### Give us a chance to serve you again.#####";
gotoxy(13,10);
cout<<"- Press 1 to add information.";
gotoxy(13,15);
cout<<"- Press 2 to modify information.";
gotoxy(13,20);
cout<<"- Press 3 to view information.";
gotoxy(13,25);
//
//==============================================================
=============
void lock()
{
textcolor(RED);
textbackground(BLACK);
for(int t=1;t<6;t++)
{
clrscr();
cout<<"\n\n\n\n\n\n
\n";
for(int i=7;i<47;i++)
{
gotoxy(11,i);
cout<<"";
}
cout<<"
\n";
for(int j=7;j<47;j++)
{
gotoxy(67,j);
cout<<"";
}
gotoxy(23,24);
cout<<"
\n";
gotoxy(23,25);
cout<<"
\n";
gotoxy(23,26);
cout<<"
\n";
gotoxy(23,27);
cout<<"
\n";
gotoxy(23,28);
cout<<"
\n";
gotoxy(23,29);
cout<<"
\n";
gotoxy(23,30);
cout<<"
\n";
gotoxy(23,31);
cout<<"
\n";
gotoxy(23,32);
cout<<"
\n";
gotoxy(23,33);
cout<<"
\n";
gotoxy(23,34);
cout<<"
\n";
gotoxy(23,35);
cout<<"
\n";
gotoxy(23,36);
cout<<"
\n";
gotoxy(23,37);
cout<<"
\n";
gotoxy(23,38);
cout<<"
";
delay(500);
gotoxy(16,14);
cout<<" THIS IS A LOCKED FEATURE,";
delay(500);
gotoxy(16,17);
cout<<" AVAILABLE WITH FULL VERSION.";
delay(500);
}
getch();
}
//==============================================================
=============
//
//
=> FUNCTION NAME: main-pre defined function.
//
=> OBJECTIVE: it is the main function from
//
which execution of the program
//
take place.
//
//
//==============================================================
=============
void main()
{
textbackground(BLACK);
textcolor(BLUE);
clrscr();
gotoxy(30,25);
cout<<"LOADING";
for(int i=0;i<10;i++)
{
cout<<".";
delay(500);
}
clrscr();
menu m;
clrscr();
railway t;
char ch;
do
{
textbackground(BLACK);
textcolor(CYAN);
clrscr();
gotoxy(18,5);
cout<<" RAILWAY DEPARTMENT ";
gotoxy(30,12);
cout<<"MAIN MENU";
gotoxy(28,13);
cout<<"-------------";
gotoxy(24,12);
cout<<"$$$$$";
gotoxy(40,12);
cout<<"$$$$$";
gotoxy(15,9) ;
cout<<"";
for(int i=10;i<42;i++)
{
gotoxy(15,i);
cout<<"";
}
for(int j=10;j<42;j++)
{
gotoxy(52,j);
cout<<"";
}
gotoxy(15,42);
cout<<"";
gotoxy(21,16);
cout<<" = 1.TRAIN INQUIRY ";
gotoxy(21,20);
cout<<" = 2.RESERVATION INQUIRY ";
gotoxy(21,24);
cout<<" = 3.TRAVEL CHARGES ";
gotoxy(21,28);
cout<<" = 4.PLATFORM INFORMATION ";
gotoxy(21,32);
cout<<" = 5.EXIT ";
gotoxy(18,48);
gotoxy(30,25);
cout<<".....FILE IS CLOSING......";
delay(500);
}
m.start();
}