diff --git a/src/scatter.nim b/src/scatter.nim index 26d7871..d8e57c2 100644 --- a/src/scatter.nim +++ b/src/scatter.nim @@ -1,6 +1,6 @@ # This is just an example to get you started. A typical binary package # uses this file as the main entry point of the application. -import system, os, random, strutils +import system, os, random, strutils,typetraits when isMainModule: #[ @@ -24,19 +24,30 @@ when isMainModule: proc geussNum() = randomize() var rng = rand(101) - while true: - stdout.write("Type a number: ") - var sroll = readLine(stdin) - var iroll = parseInt(sroll) - if rng > iroll: - echo "Number is greater" - elif rng < iroll: - echo "Number is less" - elif rng == iroll: - echo "Winner!" - quit(0) - else: - echo "not a number" + var tries = 5 + var guessed = 0 + echo "I'm thinking of a number between 1 & 100" + echo "You have ", tries, " tries" + + while guessed < tries: + stdout.write("Guess the number: ") + var guess = readLine(stdin).parseInt() + + if guess > rng: + echo "Too high" + guessed += 1 + echo "Guesses Made: ", guessed + + elif guess < rng: + echo "Too low" + guessed += 1 + echo "Guesses Made: ", guessed + + elif guess == rng: + echo "You have guessed the number: ", rng, "Good job!" + quit(0) + echo "You did not guess the number, it was : ", rng + proc help(): string =