-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
191 lines (133 loc) · 5.59 KB
/
main.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
from Car import CarRental, Customer
import random
def main():
shop = CarRental(100)
l=[]
i=0 #No customers are present
while True:
print("""
====== Car Rental Shop =======
1. Owner
2. User
""")
Login = input("Enter choice: ") #Login Is Whether (Owner/User)
try:
Login = int(Login)
except ValueError:
print("That's not an int!")
continue
if (Login == 1):
print("""
1.Display no. of Cars which currently at rent
2.Total Number of Customers visited
3.Total Rent Amount Generated
""")
Owner = input("Enter choice: ")
try:
Owner = int(Owner)
except ValueError:
print("That's not an int!")
continue
if (Owner == 1):
shop.Rentedstock()
elif (Owner == 2):
print("""
Total number of customers visited are :{} """.format(CarRental.get_subscribers()))
elif (Owner == 3):
print("Total Rent generated is equal to ${}".format(CarRental.get_totalbill()))
else:
print("Invalid input. Please enter number between 1-3 ")
elif (Login == 2):
print("""
1. Are you a New User
2. Are you a Existing User""")
User = (input())
try:
User = int(User)
except ValueError:
print("That's not an int!")
continue
if (User == 1):
customer = Customer()
l.append(customer)
print("Your customer id is:{} ".format(len(l)-1))
print("""
====== Car Rental Shop =======
1. Display available Cars
2. Request a Car on hourly basis $25
3. Request a Car on daily basis $50
4. Request a Car on weekly basis $100
5. Return a Car
6. Exit
""")
choice = input("Enter choice: ")
try:
choice = int(choice)
except ValueError:
print("That's not an int!")
continue
if choice == 1:
shop.displaystock()
elif choice == 2:
customer.rentalTime = shop.rentCarOnHourlyBasis(customer.requestCar())
customer.rentalBasis = 1
elif choice == 3:
customer.rentalTime = shop.rentCarOnDailyBasis(customer.requestCar())
customer.rentalBasis = 2
elif choice == 4:
customer.rentalTime = shop.rentCarOnWeeklyBasis(customer.requestCar())
customer.rentalBasis = 3
elif choice == 5:
customer.bill = shop.returnCar(customer.returnCar())
customer.rentalBasis, customer.rentalTime, customer.Cars = 0, 0, 0
elif choice == 6:
break
else:
print("Invalid input. Please enter number between 1-6 ")
elif(User==2): ##Existing Customer
print("""
Provide Your Customer id:""")
b=(input())
try:
b = int(b)
except ValueError:
print("That's not an int!")
continue
if(len(l)==0):
print("No customer Subscribed Yet.. ")
elif(0<=b<=len(l)):
customer=l[b]
print("""
====== Car Rental Shop =======
1. Balance History
2. Return a Car
3. Exit
""")
choice = input("Enter choice: ")
try:
choice = int(choice)
except ValueError:
print("That's not an int!")
continue
if choice ==1:
customer.rentalTime, customer.rentalBasis, customer.Cars=(customer.returnCar())
print("""
-->RentalBasis: {}
-->RentalTime: {}
-->No. of Cars taken on Rent: {}""".format(customer.rentalBasis,customer.rentalTime,customer.Cars))
elif choice == 2:
customer.bill = shop.returnCar(customer.returnCar())
customer.rentalBasis, customer.rentalTime, customer.Cars = 0, 0, 0
elif choice == 3:
break
else:
print("Invalid input. Please enter number between 1-6 ")
else:
print("Invalid Customer id.")
else:
print("Invalid input. Please enter number between 1-2 ")
else:
print("Invalid input. Please enter number between 1-2 ")
print("Thank you for using the Car rental system.")
if __name__ == "__main__":
main()