Use loop for menus
This commit is contained in:
parent
c6e71553ab
commit
78ea5d261e
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
|||||||
stockers
|
./stockers
|
@ -7,55 +7,59 @@ when isMainModule:
|
|||||||
proc casesPerMinute(name: string): string =
|
proc casesPerMinute(name: string): string =
|
||||||
var acases: float
|
var acases: float
|
||||||
var aminutes: float
|
var aminutes: float
|
||||||
|
while true == true:
|
||||||
|
|
||||||
#stdout.write("Name of employee: ")
|
#stdout.write("Name of employee: ")
|
||||||
#name = readLine(stdin)
|
#name = readLine(stdin)
|
||||||
|
|
||||||
stdout.write(fmt"Number of cases for {name}: ")
|
stdout.write(fmt"Number of cases for {name}: ")
|
||||||
var cases = readLine(stdin)
|
var cases = readLine(stdin)
|
||||||
|
|
||||||
if cases == "q":
|
if cases == "q":
|
||||||
quit(0)
|
quit(0)
|
||||||
|
|
||||||
if re"[^0-9.]" in cases:
|
if cases == "m":
|
||||||
echo "I can't do math on words, fucking moron"
|
echo "TBI"
|
||||||
quit(1)
|
|
||||||
else:
|
|
||||||
acases = cases.parseFloat()
|
|
||||||
|
|
||||||
stdout.write(fmt"Number of hours or minutes it took: ")
|
if re"[^0-9.]" in cases:
|
||||||
var minutes = readLine(stdin)
|
echo "I can't do math on words, fucking moron"
|
||||||
|
quit(1)
|
||||||
|
else:
|
||||||
|
acases = cases.parseFloat()
|
||||||
|
|
||||||
if minutes == "q":
|
stdout.write(fmt"Number of hours or minutes it took: ")
|
||||||
quit(0)
|
var minutes = readLine(stdin)
|
||||||
|
|
||||||
if re"[^0-9.]" in minutes:
|
if minutes == "q":
|
||||||
echo "I can't do math on words, fucking moron"
|
quit(0)
|
||||||
quit(1)
|
|
||||||
else:
|
if re"[^0-9.]" in minutes:
|
||||||
aminutes = minutes.parseFloat()
|
echo "I can't do math on words, fucking moron"
|
||||||
if aminutes < 10:
|
quit(1)
|
||||||
aminutes = aminutes * 60
|
else:
|
||||||
|
aminutes = minutes.parseFloat()
|
||||||
|
if aminutes < 10:
|
||||||
|
aminutes = aminutes * 60
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let cpm: float = acases / aminutes
|
let cpm: float = acases / aminutes
|
||||||
|
|
||||||
|
|
||||||
return(fmt"{name} can throw: {cpm:2.2f} cases per minute")
|
echo (fmt"{name} can throw: {cpm:2.2f} cases per minute")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proc options(name: string) =
|
proc options(name: string) =
|
||||||
echo(fmt"""
|
echo(fmt"""
|
||||||
Properties of {name}
|
Properties of {name}
|
||||||
|
|
||||||
|
|
||||||
1) Cases per minute
|
1) Cases per minute
|
||||||
q) Quit
|
q) Quit
|
||||||
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
stdout.write("Choose a property: ")
|
stdout.write("Choose a property: ")
|
||||||
var property = readLine(stdin)
|
var property = readLine(stdin)
|
||||||
@ -67,24 +71,25 @@ q) Quit
|
|||||||
echo("That is not a property")
|
echo("That is not a property")
|
||||||
|
|
||||||
|
|
||||||
proc mainScreen() =
|
proc mainScreen*() =
|
||||||
|
|
||||||
echo(fmt"""
|
echo(fmt"""
|
||||||
------------
|
------------
|
||||||
| Stockers |
|
| Stockers |
|
||||||
| v0.1.0 |
|
| v0.1.0 |
|
||||||
------------
|
------------
|
||||||
|
|
||||||
1) Leroy
|
1) Leroy
|
||||||
2) Perez
|
2) Perez
|
||||||
3) Eric
|
3) Eric
|
||||||
4) Emiliano
|
4) Emiliano
|
||||||
5) Jamal
|
5) Jamal
|
||||||
6) Joseph
|
6) Joseph
|
||||||
7) Justin
|
7) Justin
|
||||||
8) Lee
|
8) Lee
|
||||||
q) Quit
|
q) Quit
|
||||||
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
stdout.write("Choose an employee: ")
|
stdout.write("Choose an employee: ")
|
||||||
var employee = readLine(stdin)
|
var employee = readLine(stdin)
|
||||||
@ -109,5 +114,5 @@ q) Quit
|
|||||||
quit(0)
|
quit(0)
|
||||||
else:
|
else:
|
||||||
echo(fmt"{employee} is not listed above")
|
echo(fmt"{employee} is not listed above")
|
||||||
|
while true == true:
|
||||||
mainScreen()
|
mainScreen()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user