0% found this document useful (0 votes)
8 views3 pages

Train Sys

The document is a Python script for a travel booking system that allows users to select their current station and destination, view available routes and schedules, and book tickets. It includes functions to display station options, destination options, stops, schedules, and a user dashboard for booking tickets. The main function runs a loop to facilitate user interaction until a ticket is booked or the user exits.

Uploaded by

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

Train Sys

The document is a Python script for a travel booking system that allows users to select their current station and destination, view available routes and schedules, and book tickets. It includes functions to display station options, destination options, stops, schedules, and a user dashboard for booking tickets. The main function runs a loop to facilitate user interaction until a ticket is booked or the user exits.

Uploaded by

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

FINAL NANI YORR

print("="*15, "TRAVEL", "="*15)

#MO DISPLAY NI SYA SA STATIONS


def display_station():
station_options = [
"\nSelect your Current Station:",
"1. Station A",
"2. Station B",
"3. Station C",
"4. Station D",
"5. Station E",
"6. Exit"
]
for option in station_options:
print(option)

# Function to Display Destination


def display_destination():
destination_options = [
"\nSelect your Destination:",
"1. Station A",
"2. Station B",
"3. Station C",
"4. Station D",
"5. Station E",
"6. Exit"
]
for option in destination_options:
print(option)

# Function to Display Stops (DIRI AKO NING GILAHI AYPAG BUOT)


def display_stops(current_station, destination_station):
stops = {
(1, 4): "B | D",
(4, 1): "C | B",
(1, 2): "Your route is DIRECT",
(2, 1): "Your route is DIRECT",
(2, 4): "C",
(4, 2): "C",
(1, 3): "Your route is DIRECT",
(3, 1): "Your route is DIRECT"
}
route_stops = (current_station, destination_station)
if route_stops in stops:
print(f"\n==STOPS FROM STATION {current_station} TO STATION
{destination_station}: {stops[route_stops]}")
else:
print("\nNo direct route available for the selected stations.")

# Function to Display Trains and Schedules based on selected route (GI IN ANI NAKO
ARON MO OUTPUT RA ANG SPECIFIC NGA ROUTE NA IYA ADTUON)
def display_sched(current_station, destination_station):
routes = {
(1, 4): "A -> D | B, C | 6:00 a.m. | 4:00 p.m. | Every 3h",
(4, 1): "D -> A | C, B | 6:00 a.m. | 4:00 p.m. | Every 3h",
(1, 2): "A -> B | Direct | 10:30 a.m. | 3:30 p.m. | Every 1h",
(2, 1): "B -> A | Direct | 10:30 a.m. | 3:30 p.m. | Every 1h",
(2, 4): "B -> D | C | 12:45 p.m. | 5:00 p.m. | Every 2h",
(4, 2): "D -> B | C | 12:45 p.m. | 5:00 p.m. | Every 2h",
(1, 3): "A -> C | Direct | 11:00 a.m. | 4:00 p.m. | Every 1h30m",
(3, 1): "A -> C | Direct | 11:00 a.m. | 4 p.m. | Every 1h30m"
}

# Display the selected route (DIARI MO OUTPUT SYA NYA MAKITA SA USER KUNG ASA
IYANG STOP UG UNSA NGA TIME SAD IYAHA LAKAW)
selected_route = (current_station, destination_station)
if selected_route in routes:
print(f"\nROUTE FROM STATION {current_station} TO STATION
{destination_station}: ")
print(f"\n== {routes[selected_route]}")
else:
print("\nNo direct route available for the selected stations.")

# Display USER DASHBOARD


def display_dashboard():
dashboard_options = [
"\n=======================================",
"1. Book Ticket",
"2. Reset",
"3. Back to Dashboard"
]
for option in dashboard_options:
print(option)

# Main Function
def travel():
while True:
display_station()
try:
choice = int(input("\n==Select your Station (1-6): "))
except ValueError:
print("Station not found. Please input numbers only between 1 to 6")
continue
if choice == 6:
continue

if choice in range(1, 6):


display_destination()
station_two = int(input("\n==Select your Destination (1-6): "))

if station_two in range(1, 6):


display_sched(choice, station_two)
display_stops(choice, station_two)

user_input = input("\nType [BOOK] to book ticket or type [EXIT] to


exit: ").upper()
input("Press ENTER to continue")

if user_input == "BOOK":
display_dashboard()
try:
choice_one = int(input("\nEnter Choice (1-3): "))
except ValueError:
print("Invalid input. Please enter a number between 1 and
3.")
continue

if choice_one == 1:
print("\nTicket BOOKED successfully, Thank You!!")
break
elif choice_one == 2:
continue

elif choice_one == 3:
return

elif user_input == "ENTER":


display_station()
else:
print("\nThe selected station is not available or not in our
lists.")
else:
print("\nThe selected station is not available or not in our lists.")
travel()

You might also like