Python Railway Reservation
Python Railway Reservation
VIDYALAYA
Affiliated to the Central Board Of Secondary Education,Delhi
96,Vepery High Road,Vepery
Chennai-600007.Phone 25322541
Website:www.gssjainvidyalaya.com
ROLL NO:
12104
ALL INDIA SENIOR SCHOOL CERTIFICATE
EXAMINATION
2016-2017
DEPARTMENT OF COMPUTER SCIENCE
Head of Department
Computer Science
Submitted for the All India Senior Secondary School Certificate Examination
2015-2016 in Computer Science at Guru Shree Shantivijai Jain
VIdyalaya,Chennai-7
On
Practical Examinner-1
Practical Examiner 2
Date
Signature of Principal
COMPUTER
SCIENCE
PROJECT
ON
RAILWAY
RESERVATION
DONE BY:
N.DIVESH
TABLE OF CONTENT
SNO
TOPIC
1.
Introduction
2.
Algorithm
3.
Source Code
4.
Output Screen
shots
5.
Biblography
PG NO
INTRODUCTION
T h i s p r o j e c t i n t r o d u c e s r a i l w a y r e s e r v a t i o n sy ste m .
It
explains
how
reserva tion
is
being d o n e i n I n d i a n R a i l w a y s . T h e s t e p b y s t
epprocedure is explained . This project is
developed in c ++ language . Allmost all
t h e h e a d e r f i l e s h a v e b e e n u s e d i n t h i s p r o j e c t . Proper
comments
have
been
given
at
desiredl o c a t i o n s t o m a k e t h e p r o j e c t u s e r f r i e n d l y . Var
ious functions and structures are used tomake a complete use of this lan
guage.Thos
project
isw e l l v e r s e d w i t h t h e p r o g r a m m i n g . R a i l w a y reserva
tion can easily accompanied with thehelp of this.
ALGORITHM
CLASS NAME- tickets
DATA MEMBERS- no.of 1st class,no.of 2nd class,no.of 3rd
class,no.of sleeper,no.of tickets,name,age,resno,status
MEMBER FUNCTIONSret,retname,display,pending,confirmation,cancellation,reservation
OBJECT- tick
MEMBER FUNCTIONS
FUNCTION NAME- create_book()
PARAMETERS- nil
RETURN TYPE-nil
TASK-Allows the user to reads the values of book number , book
name and author name and create an book record
FUNCTION NAME- ret()
PARAMETERS- nil
RETURN TYPE- integer
TASK- returning reservation number
FUNCTION NAME-reservation()
PARAMETERS- nil
RETURN TYPE- nil
TASK-reserves the seat in particular class and prints the amount to be
paid and says whether it is confirm or waiting.
CLASS NAME- train()
DATA MEMBERS- no.of 1st class,no.of 2nd class,no.of 3rd
class,no.of sleeper,total seats,trainname,starting point,destinationpoint
MEMBER FUNCTIONS- Getinput,output,gettrain
name,gettrainno,getno.of ac class,getno.of 1st class,get no.of 2nd
class,get no.of 3rd class,getstartingpoint,getdestination
OBJECT- tr
MEMBER FUNCTIONS
FUNCTION NAME- getinput()
PARAMETERS- nil
RETURN TYPE-nil
TASK-alows user to enter the train in which he want to travel and
which class.
FUNCTION NAME- output()
PARAMETERS- nil
RETURN TYPE- nil
TASK- enters the information entered by user
FUNCTION NAME- gettrainname()
PARAMETERS- nil
RETURN TYPE- string
TASK- returns train name
FUNCTION NAME- gettrainno()
PARAMETERS- nil
RETURN TYPE- integer
TASK- returns train number
FUNCTION NAME- getno_ofac1stclass()
PARAMETERS- nil
RETURN TYPE- integer
TASK- returns first class tickets booked
PROGRAM
LISTING
else:
print
n=int(raw_input("ENTER PNR NUMBER : "))
print "\n\n"
print ("FETCHING DATA . . .".center(80))
time.sleep(1)
print
print('PLEASE WAIT...!!'.center(80))
time.sleep(1)
os.system('cls')
try:
while True:
tick=load(fin1)
if(n==tick.ret()):
f=1
print "="*80
print("PNR STATUS".center(80))
print"="*80
print
print "PASSENGER'S NAME :",tick.name
print
print "PASSENGER'S AGE :",tick.age
print
print "PNR NO :",tick.resno
print
f=1
print
print "-"*80
no_ofac1st=tr.getno_ofac1stclass()
no_ofac2nd=tr.getno_ofac2ndclass()
no_ofac3rd=tr.getno_ofac3rdclass()
no_ofsleeper=tr.getno_ofsleeper()
if(f==1):
fout1=open("tickets.dat","ab")
print
self.name=raw_input("ENTER THE PASSENGER'S
NAME ")
print
self.age=int(raw_input("PASSENGER'S AGE : "))
print
print"\t\t SELECT A CLASS YOU WOULD LIKE TO TRAVEL IN :"
print "1.AC FIRST CLASS"
print
print "2.AC SECOND CLASS"
print
print "3.AC THIRD CLASS"
print
print "4.SLEEPER CLASS"
print
dump(self,fout1)
break
else:
self.pending()
dump(tick,fout1)
break
elif(c==2):
self.no_oftickets=int(raw_input("ENTER NO_OF SECOND CLASS
AC SEATS TO BE BOOKED : "))
i=1
while(i<=self.no_oftickets):
self.totaf=self.totaf+1
amt1=900*self.no_oftickets
i=i+1
print
print "PROCESSING. .",
time.sleep(0.5)
print ".",
time.sleep(0.3)
print'.'
time.sleep(2)
os.system('cls')
print "TOTAL AMOUNT TO BE PAID = ",amt1
self.resno=random.randint(1000,2546)
x=no_ofac2nd-self.totaf
print
if(x>0):
self.confirmation()
dump(self,fout1)
break
else:
self.pending()
dump(tick,fout1)
break
elif(c==3):
self.no_oftickets=int(raw_input("ENTER NO_OF THIRD CLASS
AC SEATS TO BE BOOKED : "))
i=1
while(i<=self.no_oftickets):
self.totaf=self.totaf+1
amt1=800*self.no_oftickets
i=i+1
print
print "PROCESSING. .",
time.sleep(0.5)
print ".",
time.sleep(0.3)
print'.'
time.sleep(2)
os.system('cls')
print "TOTAL AMOUNT TO BE PAID = ",amt1
self.resno=random.randint(1000,2546)
x=no_ofac3rd-self.totaf
print
if(x>0):
self.confirmation()
dump(self,fout1)
break
else:
self.pending()
dump(tick,fout1)
break
elif(c==4):
self.no_oftickets=int(raw_input("ENTER NO_OF SLEEPER CLASS
SEATS TO BE BOOKED : "))
i=1
while(i<=self.no_oftickets):
self.totaf=self.totaf+1
amt1=550*self.no_oftickets
i=i+1
print
print "PROCESSING. .",
time.sleep(0.5)
print ".",
time.sleep(0.3)
print'.'
time.sleep(2)
os.system('cls')
print "TOTAL AMOUNT TO BE PAID = ",amt1
self.resno=random.randint(1000,2546)
x=no_ofsleeper-self.totaf
print
if(x>0):
self.confirmation()
dump(self,fout1)
break
else:
self.pending()
dump(tick,fout1)
break
except:
pass
if(f==0):
time.sleep(2)
print"\n\n\n\n\n\n\t\t\t\tNO SUCH TRAINS FOUND !!"
time.sleep(2)
print
print
print
class train:
def __init__(self):
self.trainno=0
self.no_ofac1stclass=0
self.no_ofac2ndclass=0
self.no_ofac3rdclass=0
self.no_ofsleeper=0
self.totalseats=0
self.trainname=''
self.startingpt=""
self.destination=''
defgetinput(self):
print"="*80
print "\t\t\t ENTER THE TRAIN DETAILS"
print
print"="*80
self.trainname=raw_input("ENTER THE TRAIN NAME : ").upper()
print
self.trainno=int(raw_input("ENTER THE TRAIN NUMBER: "))
print
self.no_ofac1stclass=int(raw_input("ENTER NO_OF AC FIRST
CLASS SEATS TO BE RESERVED : "))
print
self.no_ofac2ndclass=int(raw_input("ENTER NO_OF AC
SECOND CLASS SEATS TO BE RESERVED : "))
print
self.no_ofac3rdclass=int(raw_input("ENTER NO_OF AC
THIRD CLASS SEATS TO BE RESERVED : "))
print
self.no_ofsleeper=int(raw_input("ENTER NO_OF SLEEPER CLASS
+SEATS TO BE RESERVED : "))
print
self.startingpt=raw_input("ENTER THE STARTING POINT : ")
print
self.destination=raw_input("ENTER THE DESTINATION POINT :
")
os.system('cls')
def output(self):
print"="*80
print
print "THE ENTERED TRAIN NAME IS : ",self.trainname
print "THE TRAIN NUMBER IS : ",self.trainno
print "STARTING POINT ENTERED IS : ",self.startingpt
print "DESTINATION POINT ENTERED IS : ",self.destination
print "NO_OF AC FIRST CLASS SEATS RESERVED
ARE :",self.no_ofac1stclass
print "NO_OF AC SECOND CLASS SEATS RESERVED
ARE :",self.no_ofac2ndclass
def menu():
tr=train()
tick=tickets()
print
print "WELCOME TO DIVESH AGENCY".center(80)
while True:
print
print "="*80
print " \t\t\t\t RAILWAY"
print
print "="*80
print
print "\t\t\t1. **UPDATE TRAIN DETAILS."
print
print "\t\t\t2. TRAIN DETAILS. "
print
print "\t\t\t3. RESERVATION OF TICKETS."
print
print "\t\t\t4. CANCELLATION OF TICKETS. "
print
print "\t\t\t5. DISPLAY PNR STATUS."
print
print "\t\t\t6. QUIT."
print"** - office use......"
ch=int(raw_input("\t\t\tENTER YOUR CHOICE : "))
os.system('cls')
print
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\tLOAD
ING. .",
time.sleep(1)
print ("."),
time.sleep(0.5)
print (".")
time.sleep(2)
os.system('cls')
if ch==1:
j="*****"
r=raw_input("\n\n\n\n\n\n\n\n\n\n\n\t\t\t\tENTER THE
PASSWORD: ")
os.system('cls')
if (j==r):
x='y'
while (x.lower()=='y'):
fout=open("trdetails.dat","ab")
tr.getinput()
dump(tr,fout)
fout.close()
print"\n\n\n\n\n\n\n\n\n\n\n\t\t\tUPDATING TRAIN LIST PLEASE
WAIT . .",
time.sleep(1)
print ("."),
time.sleep(0.5)
print ("."),
time.sleep(2)
os.system('cls')
print "\n\n\n\n\n\n\n\n\n\n\n"
x=raw_input("\t\tDO YOU WANT TO ADD ANY
MORE TRAINS DETAILS ? ")
os.system('cls')
continue
elif(j<>r):
print"\n\n\n\n\n"
print "WRONG PASSWORD".center(80)
elifch==2:
fin=open("trdetails.dat",'rb')
if not fin:
print "ERROR"
else:
try:
while True:
print"*"*80
print"\t\t\t\tTRAIN DETAILS"
print"*"*80
print
tr=load(fin)
tr.output()
elif ch==6:
quit()
raw_input("PRESS ENTER TO GO TO BACK MENU".center(80))
os.system('cls')
menu()
print\t\t\t\t\n\n\n\n\n\t THANK YOU.....
print\n\t\t\t\DONE BY:-
print\t\t\t\t N.DIVESH
print\t\t\t\t XII-A1
print\t\t\t\t 12104
print
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\tLOAD
ING. .",
time.sleep(1)
print ("."),
time.sleep(0.5)
print (".")
time.sleep(2)
os.system('cls')
SCREEN SHOT