Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Simple Turing Game #3
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xSavage




PostPosted: Fri Oct 30, 2015 6:05 pm   Post subject: Simple Turing Game #3

What is it you are trying to achieve?
OK, so I've now finished the code and am looking for feedback on what to improve.


What is the problem you are having?



Describe what you have tried to solve this problem



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


%  #===========================#
%  #                           #
%  #   Random Number Program   #
%  #     By: Marko Medic       #
%  #       28.10.2015          #
%  #===========================#

var num : int
var guess : int
var font1 := Font.New ("Comicsans:14:bold,italic")
var i : int := 0
var continuegame : string


Font.Draw ("Welcome to the Number Game!", 200, 300, font1, red)
locate (9, 20)
color (green)
put "Instructions: The point of the game is to correctly"
locate (10, 23)
put "guess the number generated by the computer."
locate (11, 23)
put "You have a total of 10 guesses, good luck!"
locate (12, 21)
put "Remember; an invalid guess still counts as a turn!"
locate (13, 17)
put "Finally, if you want to leave at any point during the game,"
locate (14, 33)
put "simply put the number 9999."
locate (16, 35)
put "Creator: Marko Medic"
locate (17, 40)
put "29/10/2015"
locate (25, 1)
put "Press any key to begin!"


Input.Pause ()
cls

loop

    randint (num, 1, 1000)

    color (blue)
    put "Please put in a number:                        Higher, Lower or Invalid:"

    loop

        color (red)
        get guess

        i := i + 1


        if guess = 9999 then
            exit
        elsif guess > 1000 or guess < 0 then locate (1+i,65)
            put "Invalid answer."
        elsif guess > num then locate (1+i,70)
            put "Lower."
        elsif guess < num then locate (1+i,70)
            put "Higher."
        elsif guess = num then locate (1+i,70)
            put "Correct!"

        end if

        exit when guess = num or i = 10
    end loop

    if guess = num then
        put "Congratulations. You won the game in ", i, " guesses!"
    elsif guess = 9999 then
        put "                                   Sorry you have to go!"
    else
        put "Sorry. You ran out of tries at 10 guesses."
    end if

    locate (25, 1)
    put "Would you like to play again? If yes, put yes. If no, put anything except for a valid 'yes key'."
    get continuegame

    exit when ((continuegame not= 'Y') and (continuegame not= 'y') and (continuegame not= 'yes') and (continuegame not= 'Yes'))
    cls

end loop
cls







Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: