Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- loop
- % var Font : int
- % Font := Font.New ("courier :10")
- % Font.Draw ("Guess the Number!", 10, 475, Font, black)
- % Draw.Box (5, 468, 215, 497, black)
- var l : int := Rand.Int (1, limit) % Generates the number that the user is trying to guess
- Text.Locate (5, 1)
- put "Guess the number! It's between 1 and 100."
- loop
- loop
- get input
- if strintok (input) then
- z := strint (input)
- exit
- else
- put "That's not a number!"
- delay (1000)
- clearall
- Text.Locate (5, 1)
- put "Guess the number! It's between 1 and 100."
- end if
- end loop
- if z = l then
- put "Congratulations! You guessed correctly!"
- exit
- else if z > l then
- put "Try guessing lower. Keep on going."
- else if z < l then
- put "Try guessing higher. Keep on going."
- end if
- put "It took you " ..
- put counter ..
- put " guesses to guess the correct number!"
- if counter = 1 then
- put "Start buying lottery tickets!"
- else if counter <= 3 then
- put "You are an AI!"
- else if counter <= 6 then
- put "Great guessing! Move up to the next level to challenge yourself."
- else if counter <= 10 then
- put "Try guessing the number faster next time."
- else if counter >= 10 then
- put "Use better guessing strategies next time."
- end if
- end loop
- delay (1000)
- put ""
- put "Want to play the guessing game again? y/n"
- get yesorno
- if yesorno = "n" then % if user chooses not to play again
- put ""
- put "You have decided to quit, Peace!"
- delay (1000)
- exit
- else if yesorno = "y" then % if user chooses to play again
- put ""
- put "You have chosen to play again!"
- delay (1000)
- clearall
- else % Will make user play again if they do not enter either a 'y' or a 'n
- put ""
- put "Assuming that as play again"
- delay (1000)
- clearall
- end if
- end loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement