-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkq.py
36 lines (29 loc) · 1.19 KB
/
kq.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class FlightBookingApp:
def __init__(self):
self.flights = []
def add_flight(self, flight_number, destination, departure_time):
flight = {
"flight_number": flight_number,
"destination": destination,
"departure_time": departure_time,
}
self.flights.append(flight)
print(f"Flight {flight_number} to {destination} added.")
def book_flight(self, flight_number):
for flight in self.flights:
if flight["flight_number"] == flight_number:
print(f"Flight {flight_number} to {flight['destination']} booked!")
return
print(f"Flight {flight_number} not found.")
def display_flights(self):
if not self.flights:
print("No flights available.")
else:
print("Available Flights:")
for flight in self.flights:
print(f"Flight {flight['flight_number']} to {flight['destination']} at {flight['departure_time']}")
app = FlightBookingApp()
app.add_flight("KQ101", "Nairobi", "10:00 AM")
app.add_flight("KQ202", "New York", "12:00 PM")
app.display_flights()
app.book_flight("KQ101")