Skip to content

Commit 5f65be1

Browse files
authored
Update and rename simpy/simulate.py to simulation-with-simpy/simulate.py
* Run Flake and Black and reformat code for style * Remove bare try/except and replace with if/else for catching user input
1 parent 9742f65 commit 5f65be1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ def get_user_input():
8282
num_servers = input("Input # of servers working: ")
8383
num_ushers = input("Input # of ushers working: ")
8484
params = [num_cashiers, num_servers, num_ushers]
85-
try:
85+
if all(str(i).isdigit() for i in params): # Check input is valid
8686
params = [int(x) for x in params]
87-
except:
88-
print("Could not parse input. The simulation will use default values.")
87+
else:
88+
print(
89+
"Could not parse input. The simulation will use default values:",
90+
"\n1 cashier, 1 server, 1 usher.",
91+
)
8992
params = [1, 1, 1]
9093
return params
9194

@@ -102,7 +105,10 @@ def main():
102105

103106
# View the results
104107
mins, secs = calculate_wait_time(arrival_times, departure_times)
105-
print(f"The average wait time is {mins} minutes and {secs} seconds.")
108+
print(
109+
"Running simulation...",
110+
f"\nThe average wait time is {mins} minutes and {secs} seconds.",
111+
)
106112

107113

108114
if __name__ == "__main__":

0 commit comments

Comments
 (0)