forward proc declaration
This commit is contained in:
parent
3158e27882
commit
ee65f665bf
@ -1,16 +1,18 @@
|
|||||||
import strutils
|
import strutils, regex, strformat,system
|
||||||
import regex
|
|
||||||
import strformat
|
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
|
|
||||||
|
# forward declaration of functions
|
||||||
|
proc mainMenu()
|
||||||
|
proc options(name: string)
|
||||||
|
proc casesPerMinute(name: string): string
|
||||||
|
|
||||||
|
# calculate how manuy cases per minue a given person can stock
|
||||||
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: ")
|
while true:
|
||||||
#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)
|
||||||
@ -18,31 +20,32 @@ when isMainModule:
|
|||||||
if cases == "q":
|
if cases == "q":
|
||||||
quit(0)
|
quit(0)
|
||||||
|
|
||||||
if cases == "m":
|
elif cases == "m":
|
||||||
echo "TBI"
|
return
|
||||||
|
# only accept period and numbers
|
||||||
if re"[^0-9.]" in cases:
|
elif re"[^0-9.]" in cases:
|
||||||
echo "I can't do math on words, fucking moron"
|
echo "Invalid input"
|
||||||
quit(1)
|
|
||||||
else:
|
else:
|
||||||
acases = cases.parseFloat()
|
acases = cases.parseFloat()
|
||||||
|
|
||||||
stdout.write(fmt"Number of hours or minutes it took: ")
|
stdout.write("How long did it take?: ")
|
||||||
var minutes = readLine(stdin)
|
var minutes = readLine(stdin)
|
||||||
|
|
||||||
if minutes == "q":
|
if minutes == "q":
|
||||||
quit(0)
|
quit(0)
|
||||||
|
|
||||||
if re"[^0-9.]" in minutes:
|
elif minutes == "m":
|
||||||
echo "I can't do math on words, fucking moron"
|
mainMenu()
|
||||||
quit(1)
|
|
||||||
|
elif re"[^0-9.]" in minutes:
|
||||||
|
echo "Invalid input"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
aminutes = minutes.parseFloat()
|
aminutes = minutes.parseFloat()
|
||||||
if aminutes < 10:
|
if aminutes < 10:
|
||||||
aminutes = aminutes * 60
|
aminutes = aminutes * 60
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let cpm: float = acases / aminutes
|
let cpm: float = acases / aminutes
|
||||||
|
|
||||||
|
|
||||||
@ -66,27 +69,35 @@ when isMainModule:
|
|||||||
|
|
||||||
if property == "1":
|
if property == "1":
|
||||||
echo(casesPerMinute(name))
|
echo(casesPerMinute(name))
|
||||||
quit(0)
|
|
||||||
else:
|
else:
|
||||||
echo("That is not a property")
|
echo("That is not a property")
|
||||||
|
|
||||||
|
|
||||||
proc mainScreen() =
|
proc mainMenu() =
|
||||||
|
var name1: string = "Leroy"
|
||||||
|
var name2: string = "Eric"
|
||||||
|
var name3: string = "Justin"
|
||||||
|
var name4: string = "Joseph"
|
||||||
|
var name5: string = "Perez"
|
||||||
|
var name6: string = "Lee"
|
||||||
|
var name7: string = "Emiliano"
|
||||||
|
var name8: string = ""
|
||||||
|
|
||||||
echo(fmt"""
|
echo(fmt"""
|
||||||
------------
|
------------
|
||||||
| Stockers |
|
| Stockers |
|
||||||
| v0.1.0 |
|
| v0.1.0 |
|
||||||
------------
|
------------
|
||||||
|
1) {name1}
|
||||||
1) Leroy
|
2) {name2}
|
||||||
2) Perez
|
3) {name3}
|
||||||
3) Eric
|
4) {name4}
|
||||||
4) Emiliano
|
5) {name5}
|
||||||
5) Jamal
|
6) {name6}
|
||||||
6) Joseph
|
7) {name7}
|
||||||
7) Justin
|
8) {name8}
|
||||||
8) Lee
|
|
||||||
|
|
||||||
q) Quit
|
q) Quit
|
||||||
|
|
||||||
""")
|
""")
|
||||||
@ -95,24 +106,25 @@ when isMainModule:
|
|||||||
var employee = readLine(stdin)
|
var employee = readLine(stdin)
|
||||||
|
|
||||||
if employee == "1":
|
if employee == "1":
|
||||||
options("Leroy")
|
options(fmt"{name1}")
|
||||||
elif employee == "2":
|
elif employee == "2":
|
||||||
options("Perez")
|
options(fmt"{name2}")
|
||||||
elif employee == "3":
|
elif employee == "3":
|
||||||
options("Eric")
|
options(fmt"{name3}")
|
||||||
elif employee == "4":
|
elif employee == "4":
|
||||||
options("Emiliano")
|
options(fmt"{name4}")
|
||||||
elif employee == "5":
|
elif employee == "5":
|
||||||
options("Jamal")
|
options(fmt"{name5}")
|
||||||
elif employee == "6":
|
elif employee == "6":
|
||||||
options("Joseph")
|
options(fmt"{name6}")
|
||||||
elif employee == "7":
|
elif employee == "7":
|
||||||
options("Justin")
|
options(fmt"{name7}")
|
||||||
elif employee == "8":
|
elif employee == "8":
|
||||||
options("Lee")
|
options(fmt"{name8}")
|
||||||
elif employee == "q":
|
elif employee == "q":
|
||||||
quit(0)
|
quit(0)
|
||||||
else:
|
else:
|
||||||
echo(fmt"{employee} is not listed above")
|
echo(fmt"{employee} is not listed above")
|
||||||
|
|
||||||
while true == true:
|
while true == true:
|
||||||
mainScreen()
|
mainMenu()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user