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