Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 41

GURU SHREE SHANTIVIJAI JAIN

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

GURU SHREE SHANTIVIAJAI JAIN


VIDYALAYA
(Affiliated to the Central Board of Secondary Education,Delhi)
96,Vepery High Road,Vepery,Chennai-600007.Phone:25322541

DEPARTMENT OF COMPUTER SCIENCE


This is to certify that....of class has performed. During
the year 2015-2016 at the school laboratory and that his/her project report is
certified as bonafied. His/Her examination roll no is.
Chennai -600007
Date.

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- retname()


PARAMETERS- nil
RETURN TYPE- string
TASK- returns the name
FUNCTION NAME- display()
PARAMETERS- nil
RETURN TYPE- nil
TASK- print passanger name,age,pnr no.,status,no.of seats booked
FUNCTION NAME- pending()
PARAMETERS- nil
RETURN TYPE- nil
TASK-prints the pnr status
FUNCTION NAME- confirmation()
PARAMETERS- nil
RETURN TYPE- nil
TASK-prints the seat confirmation
FUNCTION NAME- cancellation()
PARAMETERS- nil
RETURN TYPE- nil
TASK-cancels the seat with pnr no.

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

FUNCTION NAME- getno_ofac2ndclass()


PARAMETERS- nil
RETURN TYPE-integer
TASK- returns no.of second class tickets booked
FUNCTION NAME- ret_token()
PARAMETERS- nil
RETURN TYPE- integer

TASK- returns the value of an students token number


FUNCTION NAME- getno_ofac3rdclass
PARAMETERS- nil
RETURN TYPE- integer
TASK- returns no.of 3rd class seats booked
FUNCTION NAME- getno_ofsleeper()
PARAMETERS- nil
RETURN TYPE- integer
TASK- returns no.of sleeper seats booked

FUNCTION NAME- getstartingpt


PARAMETERS- nil
RETURN TYPE- string
TASK- returns the starting point
FUNCTION NAME- getdestination()
PARAMETERS- nil
RETURN TYPE- string
TASK- returns destination

NON- MEMBER FUNCTIONFUNCTION NAME-menu()


PARAMETERS-nil
RETURN TYPE- nil
TASK-calls getinput,output,reservation,cancellation,display and
creates files trdetails.dat and tickdetails.dat

PROGRAM
LISTING

from pickle import load,dump


import time
import random
importos
class tickets:
def __init__(self):
self.no_ofac1stclass=0
self.totaf=0
self.no_ofac2ndclass=0
self.no_ofac3rdclass=0
self.no_ofsleeper=0
self.no_oftickets=0
self.name=''
self.age=''
self.resno=0
self.status=''
def ret(self):
return(self.resno)
defretname(self):
return(self.name)
def display(self):
f=0
fin1=open("tickets.dat","rb")
if not fin1:
print "ERROR"

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

print "STATUS :",tick.status


print
print "NO OF SEATS BOOKED : ",tick.no_oftickets
print
except:
pass
fin1.close()
if(f==0):
print
print "WRONG PNR NUMBER..!!"
print
def pending(self):
self.status="WAITING LIST"
print "PNR NUMBER :",self.resno
print
time.sleep(1.2)
print "STATUS = ",self.status
print
print "NO OF SEATS BOOKED : ",self.no_oftickets
print
def confirmation (self):
self.status="CONFIRMED"
print "PNR NUMBER : ",self.resno
print
time.sleep(1.5)

print "STATUS = ",self.status


print
def cancellation(self):
z=0
f=0
fin=open("tickets.dat","rb")
fout=open("temp.dat","ab")
print
r= int(raw_input("ENTER PNR NUMBER : "))
try:
while(True):
tick=load(fin)
z=tick.ret()
if(z!=r):
dump(tick,fout)
elif(z==r):
f=1
except:
pass
fin.close()
fout.close()
os.remove("tickets.dat")
os.rename("temp.dat","tickets.dat")
if (f==0):
print

print "NO SUCH RESERVATION NUMBER FOUND"


print
time.sleep(2)
os.system('cls')
else:
print
print "TICKET CANCELLED"
print
def reservation(self):
trainno=int(raw_input("ENTER THE TRAIN NO:"))
z=0
f=0
fin2=open("trdetails.dat")
fin2.seek(0)
if not fin2:
print "ERROR"
else:
try:
while True:
tr=load(fin2)
z=tr.gettrainno()
n=tr.gettrainname()
if (trainno==z):
print
print "TRAIN NAME IS : ",n

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

c=int(raw_input("\t\t\tENTER YOUR CHOICE = "))


os.system('cls')
amt1=0
if(c==1):
self.no_oftickets=int(raw_input("ENTER NO_OF FIRST CLASS AC
SEATS TO BE BOOKED : "))
i=1
while(i<=self.no_oftickets):
self.totaf=self.totaf+1
amt1=1000*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=int(random.randint(1000,2546))
x=no_ofac1st-self.totaf
print
if(x>0):
self.confirmation()

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

print "NO_OF AC THIRD CLASS SEATS RESERVED


ARE :",self.no_ofac3rdclass
print "NO_OF SLEEPER CLASS SEATS RESERVED
ARE :",self.no_ofsleeper
print
print "="*80
def gettrainname(self):
return (self.trainname)
def gettrainno(self):
return(self.trainno)
def getno_ofac1stclass(self):
return(self.no_ofac1stclass)
def getno_ofac2ndclass(self):
return(self.no_ofac2ndclass)
def getno_ofac3rdclass(self):
return(self.no_ofac3rdclass)
def getno_ofsleeper(self):
return (self.no_ofsleeper)
def getstartingpt(self):
return (self.startingpt)
def getdestination(self):
return (self.destination)

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()

raw_input("PRESS ENTER TO VIEW NEXT TRAIN DETAILS")


os.system('cls')
exceptEOFError:
pass
elifch==3:
print'='*80
print "\t\t\t\tRESERVATION OF TICKETS"
print'='*80
print
tick.reservation()
elifch==4:
print"="*80
print"\t\t\t\tCANCELLATION OF TICKETS"
print
print"="*80
print
tick.cancellation()
elifch==5:
print "="*80
print("PNR STATUS".center(80))
print"="*80
print
tick.display()

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

You might also like