0% found this document useful (0 votes)
15 views19 pages

Cs Project Mayank-Rehan-1

Uploaded by

mayank.mohanty05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views19 pages

Cs Project Mayank-Rehan-1

Uploaded by

mayank.mohanty05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

PM SHRI KENDRIYA VIDYALAYA NO:1

A.F.S TAMBARAM

XII COMPUTER SCIENCE


RAILWAY RESERVATION SYSTEM
2024-2025
DONE BY: MAYANK, REHAN (XII-C)
PROJECT MENTOR: MR. JITENDRA SHARMA
CERTIFICATE
This is to certify that this project report entitled “Railway
Reservation System” is a bonafide record of the project work
done by Mayank and Rehan of class 12th- C in the academic
year 2024 – 2025. The project has been submitted in partial
fulfillment of AISSCE for practical held at PM SHRI
KENDRIYA VIDYALAYA No:1 A.F.S Tambaram

Date:…………… Teacher in Charge:


Mr. JITENDRA SHARMA
PGT Comp science

Internal Examiner External Examiner

PRINCIPAL

ACKNOWLEDGEMENT
We take this opportunity to place record on my profound respect
to our principal MR. S.ARUMUGAM for guiding light to our
success.

we would like to thank our subject teacher MR. JITENDRA


SHARMA (P.G.T Computer science) who had guided,
encouraged and supported us to do this project work
successfully.

We both are really fortunate to receive the blessings from our


parents whose profound love was the source of inspiration for
our endeavors.

we thank our friends and classmates who helped us throughout


the project work
INDEX

Sno: Title Page No:


1 INTRODUCTION
2 OBJECTIVE
3 SOFTWARE REQUIREMENTS
4 HARDWARE REQUIREMENTS
5 MODULE IDENTFICATION
6 SOURCE CODE
7 OUTPUT
8 LIMITATIONS
9 CONCLUSION
10 BIBLIOGRAPHY
Introduction to the project

The topic of the project is railway reservation system. The


railway reservation system facilitates the passengers to inquire
about the trains available on the basis of source and
destination, booking and cancellation of tickets, enquiry about
the status of booked ticket, etc. The aim of case study is to
design and develop a database maintaining records of
different trains train status and passengers. This project
contains introduction to the railways reservation system. It is
computerized system of the reserving the seats of train in
advance. It is mainly used for a long route. Online reservation
has made the process for the reservation of seats very much
easier than ever before.
OBJECTIVE
The project "online railway ticket reservation program" is
dedicated to the general requirement of railway systems. the
main objective of this project is to create an online railway
ticket reservation program that allows customer to know about
new trains, their schedules, station location class and ticket
price etc. In the booking process when customer selects his
station from where he wants to go. In the next step he/she
selects his station then the trains are filtered. In the next steps
he/she selects the desired train from where he/she wants to
move & then train and other details like train date, time, class,
station number and number of ticket based on given parameter
, a graphical layout of seat status is visible to the customer.
Now customer can select his desired seat location and the
number of seats the administrator will be able to see all
booked and cancel tickets.
The main objective of this project are these:-
Facility to store the information of new customer different
types of train, train timing, tickets rate etc. Interest to develop
a good user friendly website with many online transaction
using a database. Facility to generate different reports which
are helpful for the management in decision making. System
should also provide accessories such as calculator , month
viewer.Additionally some display setting options can also be
provided
Software requirements
 A window-based operating system with DOS support
 The system must be connected with a LAN connection
 Python

Hardware requirements
 The hardware requirements are laptop of 4.00GB 32-bit
operating system
 Printer
Module Identification
User Interface Module:
Functions to display a menu for the user to input travel details (e.g.,
origin, destination, date). Functions to display available trains and
their schedules. Functions to allow the user to select a train and seat

Database Module:
Functions to connect to a database where train schedules and booking
information are stored. Functions to query the database for available
trains based on the user's input. Functions to update seat availability
after a booking is made.

Booking Module:
Functions to reserve seats for a specific train. Functions to calculate
the fare based on the selected seats and any additional options (e.g.,
class of travel).Functions to handle payment processing and confirm
bookings.

Ticket Generation Module:


Functions to generate a booking confirmation with details such as the
train name, departure time, seat numbers, and fare. Functions to
format the booking confirmation for printing or emailing to the user.

Main Application Module:


Functions to initialize the application and set up any necessary
configurations. Functions to handle the overall flow of the booking
process, such as collecting user input, interacting with the database,
and managing bookings. Functions to handle exceptions and errors
gracefully.
SOURCE CODE
# Train Booking System

# Database Module: Database of trains available for booking


trains = [
{"id": "101", "name": "Express", "origin": "CityA", "dest":
"CityB", "date": "2024-06-22", "departuretime": "10:00
AM"},
{"id": "102", "name": "Superfast", "origin": "CityA",
"dest": "CityB", "date": "2024-06-22", "departuretime":
"02:00 PM"},
]

# Database Module: Seat availability for each train


seats = {
"101": {"1A": True, "1B": True, "2A": True, "2B": True},
"102": {"1A": True, "1B": True, "2A": True, "2B": True},
}

# User Interface Module: Function to display the main menu


def menu():
print("Welcome to Train Booking")
print("1. Search Trains")
print("2. Exit")
ch = input("Enter your choice: ")
return ch
# User Interface Module: Function to gather travel details from the
user
def travel_details():
print("Select origin:")
print("1. CityA")
print("2. CityB")
origin_choice = input("Enter origin: ")

origins = {
'1': 'CityA',
'2': 'CityB'
}
origin = origins.get(origin_choice)

print("Select destination:")
print("1. CityX")
print("2. CityY")
destination_choice = input("Enter destination: ")

destinations = {
'1': 'CityX',
'2': 'CityY'
}
destination = destinations.get(destination_choice)

travel_date = input("Enter travel date (yyyy-mm-dd): ")


return origin, destination, travel_date
# User Interface Module: Function to display available trains based
on search criteria
def show_trains(trains):
print("Available trains:")
for train in trains:
print(f"Train ID: {train['id']}, Name: {train['name']},
Departure: {train['departuretime']}")

# User Interface Module: Function to select a train and a seat


def select_train_seat():
print("Select a train:")
for train in trains:
print(f"Train ID: {train['id']}")

train_id = input("Enter train ID: ")

if train_id not in seats:


print("Invalid train ID.")
return None, None

print(f"Available seats for Train ID: {train_id}")


seats_available = [seat for seat, available in
seats[train_id].items() if available]
if not seats_available:
print("No seats available.")
return None, None

for seat in seats_available:


print(f"Seat: {seat}")

seat_number = input("Enter seat number: ")


return train_id, seat_number
# Database Module: Function to find trains based on user input
def find_trains(fromloc, toloc, traveldate):
available_trains = [t for t in trains if t['origin'] == fromloc
and t['dest'] == toloc and t['date'] == traveldate]
return available_trains

# Database Module: Function to update the seat availability when


booked
def update_seat(tid, seatno):
if tid in seats and seatno in seats[tid]:
seats[tid][seatno] = False

# Booking Module: Function to reserve a seat for a given train


def reserve(tid, seatno):
if seats[tid][seatno]:
update_seat(tid, seatno)
print(f"Seat {seatno} on train {tid} has been reserved.")
else:
print("This seat is already reserved.")

# Booking Module: Function to calculate the fare based on seat


class
def calc_fare(seatno, travelclass):
basefare = 50
if travelclass == 'first':
return basefare * 1.5
return basefare

# Booking Module: Function to simulate payment


processing
def pay(fare):
print("Processing payment of $" + str(fare))
return True
# Booking Module: Function to confirm the booking to the user
def confirm(tid, seatno, fare):
print("Booking confirmed for train " + tid + ", seat " +
seatno + ". Total fare: $" + str(fare))

# Ticket Generation Module: Function to generate


confirmation details
def gen_confirm(tid, seatno, fare):
return {
'trainid': tid,
'seatno': seatno,
'fare': fare
}

# Ticket Generation Module: Function to format the


confirmation details for display
def format_confirm(confirm, fmt="text"):
if fmt == "text":
return f"Train ID: {confirm['trainid']}, Seat Number:
{confirm['seatno']}, Fare: ${confirm['fare']}"
elif fmt == "email":
return (f"Booking Confirmation\n"
f"Train ID: {confirm['trainid']}\n"
f"Seat Number: {confirm['seatno']}\n"
f"Fare: ${confirm['fare']}")

# Main Application Module: Function to initialize the


application
def init_app():
print("Starting Train Booking System...")
# Main Application Module: Main function to run the
application
def run():
while True:
ch = menu()
if ch == '1':
fromloc, toloc, traveldate = travel_details()
available_trains = find_trains(fromloc, toloc,
traveldate)
show_trains(available_trains)
tid, seatno = select_train_seat()
if tid and seatno:
travelclass = input("Enter travel class
(standard/first): ")
fare = calc_fare(seatno, travelclass)
if pay(fare):
reserve(tid, seatno)
booking_info = gen_confirm(tid, seatno, fare)
print(format_confirm(booking_info))
elif ch == '2':
print("Exiting...")
break
else:
print("Invalid choice. Try again.")

# Entry point for the application


if __name__ == "__main__":
init_app()
run()
OUTPUT
Limitations
The provided code has several limitations and areas for improvement,
including:

1. Hardcoded Data:

The train and seat data are hardcoded in the script, making it inflexible
and unsuitable for real-world applications where data would typically
be dynamic and stored in a database.

2. Limited Destinations:

The code only supports searching between predefined origins and


destinations (CityA, CityB, CityX, CityY). This does not reflect a
realistic train booking system with multiple possible locations.

3. Date Input Handling:

The date input handling is simplistic and doesn't validate the format or
ensure the date is in a valid range (e.g., not in the past).

4. Static Seat Reservation:

The seat reservation updates the seats dictionary but doesn't persist
these changes. In a real system, this should update a database to reflect
the reservation.

5. No Error Handling:

The code lacks error handling for invalid inputs, such as entering an
invalid train ID or seat number.

There is no handling for cases where no trains are available for the given
search criteria.
6. Payment Processing:

The payment processing is simulated with a simple print statement. In a real-


world application, this would need to integrate with a payment gateway and
handle success or failure cases.

7. User Interface:

The user interface is basic and text-based, which is not user-friendly. Modern
applications typically have graphical interfaces or web-based frontends.

8. Seat Availability:

The code does not handle concurrent reservations. Multiple users could
potentially reserve the same seat due to the lack of synchronization.

9. Limited Fare Calculation:

The fare calculation is very basic, only differentiating between "first" and
"standard" class without considering other factors like distance or dynamic
pricing.

10.Modularization and Code Structure:

Although some functions are modularized, there is still a mixture of logic that
could be better organized, particularly with separating concerns like data access,
business logic, and user interface.

11.Security Concerns:

The code does not address any security concerns, such as sanitizing inputs to
prevent injection attacks or ensuring secure handling of payment information.

12.No Logging or Monitoring:

There is no logging mechanism to track user actions or system behavior, which


is essential for debugging and monitoring in a production environment.

By addressing these limitations, the code can be transformed into a more robust,
secure, and user-friendly train booking system suitable for real-world use.
Analysis and Conclusion
The provided code is a basic simulation of a train booking system, illustrating
core functionalities such as train search, seat selection, fare calculation,
payment processing, and booking confirmation. While it serves as a good
starting point for a train reservation system, there are several areas where the
code can be improved to make it more robust, scalable, and user-friendly.

Key Features of the Code:

1. Menu Interface:
o The code provides a simple text-based menu for interacting with
the train booking system.
o Users can choose to search for trains or exit the application.
2. Travel Details Input:
o The system prompts users to select the origin, destination, and
travel date.
o The origins and destinations are limited to predefined values.
3. Train Search and Display:
o The system searches for available trains based on the user’s input
and displays the results.
4. Seat Selection:
o Users can select a train and then choose an available seat on that
train.
5. Fare Calculation and Payment:
o The fare is calculated based on a base fare, with a multiplier for
first-class seats.
o The payment process is simulated with a print statement.
6. Reservation and Confirmation:
o Once payment is processed, the seat is reserved, and a booking
confirmation is generated and displayed.
BIBLIOGRAPHY

 Computer Science with Python – By Sumita Arora


 Wikipedia
 Chat GPT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy