-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbusbooking.py
34 lines (27 loc) · 985 Bytes
/
busbooking.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
#A simple busbooking system
class Bus:
def __init__(self, name, fare, seats):
self.name = name
self.fare = fare
self.seats = seats
def getStatus(self):
print("**************************************************")
print(f"The name of the Bus is {self.name}")
print(f"The seats available in the Bus are {self.seats}")
print("**************************************************")
def ticketInfo(self):
print(f"The price of the ticket is: Rs {self.ticketInfo}")
def bookTicket(self):
if(self.seats>0):
print(f"Your ticket has been booked! Your seat number is {self.seats}")
self.seats = self.seats - 1
else:
print("Sorry this Bus is full! Kindly try another one")
def cancelTicket(self, seatNo):
pass
udupi = Bus("Kundapur Express: 1000", 50, 2)
udupi.getStatus()
udupi.bookTicket()
udupi.bookTicket()
udupi.bookTicket()
udupi.getStatus()