create procs for cpm and options

This commit is contained in:
mollusk 2019-12-19 14:34:09 -07:00
parent 4ff6e01337
commit 0341ba3a45
2 changed files with 78 additions and 25 deletions

View File

@ -3,39 +3,92 @@ import regex
import strformat
when isMainModule:
var acases: float
var aminutes: float
var name: string
var time_tail = "hours"
stdout.write("Name of employee: ")
name = readLine(stdin)
proc casesPerMinute(name: string): string =
var acases: float
var aminutes: float
stdout.write("Number of cases: ")
var cases = readLine(stdin)
#stdout.write("Name of employee: ")
#name = readLine(stdin)
stdout.write(fmt"Number of cases for {name}: ")
var cases = readLine(stdin)
if cases == "q":
quit(0)
if re"[^0-9.]" in cases:
echo "I can't do math on words, fucking moron"
quit(1)
else:
acases = cases.parseFloat()
stdout.write(fmt"Number of hours or minutes it took: ")
var minutes = readLine(stdin)
if minutes == "q":
quit(0)
if re"[^0-9.]" in minutes:
echo "I can't do math on words, fucking moron"
quit(1)
else:
aminutes = minutes.parseFloat()
if aminutes < 10:
aminutes = aminutes * 60
if re"[^0-9.]" in cases:
echo "I can't do math on words, fucking moron"
quit(1)
else:
acases = cases.parseFloat()
let cpm: float = acases / aminutes
stdout.write("Number of minutes it took: ")
var minutes = readLine(stdin)
if re"[^0-9.]" in minutes:
echo "I can't do math on words, fucking moron"
quit(1)
else:
aminutes = minutes.parseFloat()
if aminutes < 10:
aminutes = aminutes * 60
return(fmt"{name} can throw: {cpm:2.2f} cases per minute")
let cpm: float = acases / aminutes
proc options(name: string) =
echo(fmt"""
Properties of {name}
echo(fmt"{name} can throw: {cpm:2.2f} cases per minute")
1) Cases per minute
q) Quit
""")
stdout.write("Choose a property: ")
var property = readLine(stdin)
if property == "1":
echo(casesPerMinute(name))
quit(0)
else:
echo("That is not a property")
proc mainScreen() =
echo("""
1) Leroy
2) Perez
3) Eric
4) Emiliano
5) Jamal
6) Joseph
7) Justin
8) Lee
q) Quit
""")
stdout.write("Choose an employee: ")
var employee = readLine(stdin)
if employee == "1":
options("Leroy")
elif employee == "q":
quit(0)
mainScreen()

BIN
stockers

Binary file not shown.