diff --git a/src/stockers.nim b/src/stockers.nim index aa3d833..87592d6 100644 --- a/src/stockers.nim +++ b/src/stockers.nim @@ -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 re"[^0-9.]" in cases: - echo "I can't do math on words, fucking moron" - quit(1) - else: - acases = cases.parseFloat() + 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("Number of minutes it took: ") - var minutes = readLine(stdin) + stdout.write(fmt"Number of hours or 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 + 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 - 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() \ No newline at end of file diff --git a/stockers b/stockers index c5496a2..3bad776 100755 Binary files a/stockers and b/stockers differ