-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCarsStack.py
More file actions
222 lines (184 loc) · 5.13 KB
/
CarsStack.py
File metadata and controls
222 lines (184 loc) · 5.13 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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import time
import os
from os import system, name
def clear():
# for windows
if name == 'nt':
_ = system('cls')
# for mac and linux(here, os.name is 'posix')
else:
_ = system('clear')
carGarage = []
tempGarage = []
carEntered = {}
carExited = {}
carGone = []
#cars = ['ABC 1234', 'DEF 5678', 'GHI 9101', 'JKL 1213', 'MNO 1415', 'PQR 1617', 'STU 1819','VWX 2021', 'YZA 2223', 'BCD 2425']
cars = []
def userOption():
menu = """
[Garage Management]
:Process Menu:
1) Add Car to the Garage.
2) Get Car out of the Garage.
3) Check Garage Capacity.
4) View all cars in the Garage.
5) Check Arrival and Departure Counter.
6) Yeet all cars out of the Garage.
7) End Program.
"""
print(menu)
userInput = input("What do you want to do?: ")
if userInput.isdigit():
optionPass = userInput
processPass(optionPass)
else:
print("\n[Error] Carefully choose from the options above!")
time.sleep(3)
clear()
time.sleep(2)
userOption()
def processPass(option):
if option == "1":
addCar()
elif option == "2":
removeCar()
elif option == "3":
checkGarage("a")
print(carGarage)
time.sleep(5)
clear()
userOption()
elif option == "4":
return
elif option == "5":
return
elif option == "6":
yeetAll()
elif option == "7":
print("\nThank you for using Garage Management.")
time.sleep(3)
print("Goodbye :)")
time.sleep(2)
clear()
exit()
else:
print("\n[Error] Unknown command. Please try again :(")
time.sleep(3)
clear()
userOption()
def carEn():
for car in carEntered.keys():
if (car not in carGone):
carEntered[car] += 1
tempGarage.clear()
def carEx():
for car in carExited.keys():
if (car not in carGone):
carExited[car] += 1
yeet = len(tempGarage)
print("\n Car {} left the garage for good :( \n".format(tempGarage[yeet-1]))
carGone.append(tempGarage[yeet-1])
tempGarage.pop()
def addCar():
print("\n[ Adding a Car to the Garage ]")
print("[ Plate Number Example = ABC 123 ]")
newCar = str(input("\nNew Car's Plate Number: "))
if not newCar:
print("\n[Error] Please enter a Plate Number!")
time.sleep(3)
clear()
time.sleep(2)
addCar()
else:
if len(newCar) != 7:
print("\n[Error] Please follow the prescribed plate configuration!")
time.sleep(3)
clear()
time.sleep(2)
addCar()
else:
cars.append(newCar)
carInit()
return
def removeCar():
print("\n[ Please Enter the Leaving Car's Plate Number ]")
print("Cars List: "+carGarage)
newCar = str(input("\nCar's Plate Number: "))
return
def checkGarage(string):
chkGarage = len(carGarage)
if string == "a":
if chkGarage > 10:
print("Garage capacity on maximum. [!]")
return False
else:
print(" Garage has {} available space.".format(10-chkGarage))
if string == "b":
print(" Garage has {} available space.".format(10-chkGarage))
def checkCarHist():
print("Sum of all car entries: ", sum(carEntered.values()))
print(carEntered)
print("\nSum of all car exits: ", sum(carExited.values()))
print(carExited)
def carInit():
print("[ Car Valet: ]")
i=0
for c in cars:
while i < len(cars):
car = cars[i]
time.sleep(1)
print("{} added to the garage".format(car))
carGarage.append(car)
checkGarage("a")
print("")
e = {str(car) : 0}
carEntered.update(e)
carExited.update(e)
i+=1
for car in carEntered.keys():
carEntered[car] += 1
def carEnt():
i = 0
j = len(tempGarage)
for c in tempGarage:
while i < j:
car = tempGarage[j-(i+1)]
time.sleep(1)
print("{} entered the garage".format(car))
carGarage.append(car)
checkGarage("a")
print("")
i+=1
carEn()
def carExt():
i = 0
j = len(carGarage)
for c in carGarage:
while i < j:
car = carGarage[j-(i+1)]
time.sleep(1)
print("{} transferred to the temporary garage.".format(car))
tempGarage.append(car)
carGarage.pop()
checkGarage("b")
print("")
i+=1
carEx()
def yeetAll():
carInit()
while (len(tempGarage) or len(carGarage)) != 0:
time.sleep(1)
print("\n[A car decided to get out of the garage.]\n")
carExt()
#print("Car Transferred: ", carExited)
time.sleep(1)
carEnt()
#print("\nCar Entered: \n", carEntered)
print("")
time.sleep(1)
checkCarHist()
time.sleep(5)
print("titiw :3")
while True:
userOption()