-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgee.py
More file actions
99 lines (73 loc) · 2.51 KB
/
gee.py
File metadata and controls
99 lines (73 loc) · 2.51 KB
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
class Dog:
attr1 = 'Mammal'
attr2 = 'Dog'
def fun(self):
print(f'I am a {self.attr1}')
print(f'I am a {self.attr2}')
Rodger = Dog()
print(Rodger.attr1)
Rodger.fun()
print(Rodger.attr2)
class Person:
def __init__(self, name):
self.name = name
def say_hi(self):
print(f'Hello, my name is {self.name}')
p = Person('Nicki')
p.say_hi()
name = input('Enter your name: ')
print(f'Hi! {name}, welcome to the car rental system')
class Rental:
def __init__(self, list, name):
self._carlist = list
self._name = name
self._lendDict = {}
def Displaycars(self):
print(f'List of cars available for rent are here:\n', self._name)
for car in self._carlist:
print(car)
def Lendcars(self, user, car):
if car not in self._lendDict.keys():
self._lendDict.update({car:user})
print('Lender-car is updated in system, you can take car with you')
else:
print(f'Car is already being used by {self._lendDict[car]}')
def Addcar(self, car):
if car not in self._carlist:
self._carlist.append(car)
else:
pass
print('Car database is updated now')
def Returncar(self, car):
self._lendDict.pop(car)
print('Your car has been returned!')
if __name__ == '__main__':
rental = Rental(['Rav4', 'Camry', 'Hyundai-i10', 'KIA'], 'Mike Car rental')
while(True):
print(f'Welcome to the {rental._name} management system, Enter your choice here')
print('1, Display cars')
print('2, Lend a car')
print('3, Add a car')
print('4, Return a car')
print('5, Exit')
user_choice = int(input('Your choice??'))
if user_choice not in [1,2,3,4,5]:
print('Not a valid choice, please choose again')
break
else:
user_choice = user_choice
if user_choice == 1:
rental.Displaycars()
elif user_choice == 2:
print(f'car list {rental._carlist}')
user = input("Enter your 'name': ")
car = input('Enter the name of the car you want: ')
rental.Lendcars(user, car)
elif user_choice == 3:
car = input("Enter the car name: ")
rental.Addcar(car)
elif user_choice == 4:
car = input('Enter the car to return')
rental.Returncar(car)
else:
break