create procs for cpm and options
This commit is contained in:
parent
4ff6e01337
commit
0341ba3a45
103
src/stockers.nim
103
src/stockers.nim
@ -3,39 +3,92 @@ import regex
|
|||||||
import strformat
|
import strformat
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
var acases: float
|
|
||||||
var aminutes: float
|
|
||||||
var name: string
|
|
||||||
var time_tail = "hours"
|
|
||||||
|
|
||||||
stdout.write("Name of employee: ")
|
proc casesPerMinute(name: string): string =
|
||||||
name = readLine(stdin)
|
var acases: float
|
||||||
|
var aminutes: float
|
||||||
|
|
||||||
stdout.write("Number of cases: ")
|
#stdout.write("Name of employee: ")
|
||||||
var cases = readLine(stdin)
|
#name = readLine(stdin)
|
||||||
|
|
||||||
|
stdout.write(fmt"Number of cases for {name}: ")
|
||||||
|
var cases = readLine(stdin)
|
||||||
|
|
||||||
|
if cases == "q":
|
||||||
if re"[^0-9.]" in cases:
|
quit(0)
|
||||||
echo "I can't do math on words, fucking moron"
|
|
||||||
quit(1)
|
if re"[^0-9.]" in cases:
|
||||||
else:
|
echo "I can't do math on words, fucking moron"
|
||||||
acases = cases.parseFloat()
|
quit(1)
|
||||||
|
else:
|
||||||
|
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 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
|
||||||
|
|
||||||
|
|
||||||
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()
|
Loading…
x
Reference in New Issue
Block a user