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,18 +3,19 @@ import regex
import strformat import strformat
when isMainModule: when isMainModule:
proc casesPerMinute(name: string): string =
var acases: float var acases: float
var aminutes: float var aminutes: float
var name: string
var time_tail = "hours"
stdout.write("Name of employee: ") #stdout.write("Name of employee: ")
name = readLine(stdin) #name = readLine(stdin)
stdout.write("Number of cases: ") stdout.write(fmt"Number of cases for {name}: ")
var cases = readLine(stdin) var cases = readLine(stdin)
if cases == "q":
quit(0)
if re"[^0-9.]" in cases: if re"[^0-9.]" in cases:
echo "I can't do math on words, fucking moron" echo "I can't do math on words, fucking moron"
@ -22,9 +23,12 @@ when isMainModule:
else: else:
acases = cases.parseFloat() acases = cases.parseFloat()
stdout.write("Number of minutes it took: ") stdout.write(fmt"Number of hours or minutes it took: ")
var minutes = readLine(stdin) var minutes = readLine(stdin)
if minutes == "q":
quit(0)
if re"[^0-9.]" in minutes: if re"[^0-9.]" in minutes:
echo "I can't do math on words, fucking moron" echo "I can't do math on words, fucking moron"
quit(1) quit(1)
@ -38,4 +42,53 @@ when isMainModule:
let cpm: float = acases / aminutes let cpm: float = acases / aminutes
echo(fmt"{name} can throw: {cpm:2.2f} cases per minute") return(fmt"{name} can throw: {cpm:2.2f} cases per minute")
proc options(name: string) =
echo(fmt"""
Properties of {name}
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.