railway reservation python code

Hey guys,

The project is based on cbse curriculum

Full code is not been displayed here

For getting the whole code

Whatsapp me at 9884523855

Mind you nothing is given for free






         Options and the first screen of project goes this way










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  FUNCTIONS- ret,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 student’s 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 FUNCTION-

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









A bit of code is displayed here

#_________________HEADER_________________
from pickle import load,dump
import time
import random
import os
#_______________________CLASS TICKETS_________________
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=''       \
#__________RETURNS RESERVATION NUMBER___________
    def ret(self):
        return(self.resno)

#___________RETURNS NAME_____________
    def retname(self):
        return(self.name)
#_________________DISPLAYS THE DATA_______________
    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


Comments