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

Username:   Password: 
 RegisterRegister   
 hangman help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
qwertyuiop




PostPosted: Wed Dec 06, 2006 5:25 pm   Post subject: hangman help

hey i am starting my hangman program and i want the user to enter a word and i want to have that word changed into dashes... this is what i have so far... can n e one point out my problem?
code:
var puzzle : string
var puzzle2 : string := ""
%var guess : string (1)
%var count, wrong : int := 0

put "enter puzzle"
get puzzle : *
puzzle := Str.Upper (puzzle)
for i : 1 .. length (puzzle)
    if i >= "A" and i <= "Z" then
        puzzle2 := puzzle2 + "_"
    end if
end for
put puzzle2
Sponsor
Sponsor
Sponsor
sponsor
NikG




PostPosted: Thu Dec 07, 2006 3:49 pm   Post subject: Re: hangman help

qwertyuiop wrote:
code:
if i >= "A" and i <= "Z" then
How will this ever work?? i is a number, and you're comparing it to letters.

Hope that clue helps.
Piro24




PostPosted: Thu Dec 07, 2006 5:34 pm   Post subject: (No subject)

If is all you want to do is convert letters to dashes than just use catentation (sp?) and a for loop


code:

var word : string
put "Enter word"
get word
cls
for i : 1 .. length (word)
    put " _ " ..
end for
TokenHerbz




PostPosted: Fri Dec 08, 2006 3:20 am   Post subject: (No subject)

Eww, Str.Upper!

code:

var secretText : string             %%This will be your word.
var uncoverText : flexible array 1 .. 0 of string   %%This will be your progres
var input : string (1)              %%gets input
var blockOut : string := "*"        %%can change this ex: "_"

get secretText : *                  %%Gets your text.

for i : 1 .. length (secretText)    %%sets progress
    new uncoverText, upper (uncoverText) + 1
    if ord (secretText (i)) <= 90 and ord (secretText (i)) >= 65 or
            ord (secretText (i)) <= 122 and ord (secretText (i)) >= 97 then
        uncoverText (i) := blockOut
    else
        uncoverText (i) := secretText (i) %%shows non letter chars
    end if
end for

%%main loop
loop
    cls
    for i : 1 .. upper (uncoverText)        %%display current progress
        put uncoverText (i) ..
    end for

    put ""
    put "Enter a letter: " ..
    getch (input)

    %%this will search for the letter, and if its there show it
    for i : 1 .. length (secretText)
        if ord (secretText (i)) = ord (input) then
            uncoverText (i) := input    %%yay shows you it!
        end if
    end for
end loop

%%TO DO LIST
%%have it so you lose after 5 failed attempts
%%have it draw a hang man!
%%make my crappy codeing better


Woot woot! 7 mins to make
Cleev




PostPosted: Thu Jun 14, 2007 6:25 pm   Post subject: (No subject)

TokenHerbz @ Fri Dec 08, 2006 3:20 am wrote:
Eww, Str.Upper!

code:

var secretText : string             %%This will be your word.
var uncoverText : flexible array 1 .. 0 of string   %%This will be your progres
var input : string (1)              %%gets input
var blockOut : string := "*"        %%can change this ex: "_"

get secretText : *                  %%Gets your text.

for i : 1 .. length (secretText)    %%sets progress
    new uncoverText, upper (uncoverText) + 1
    if ord (secretText (i)) <= 90 and ord (secretText (i)) >= 65 or
            ord (secretText (i)) <= 122 and ord (secretText (i)) >= 97 then
        uncoverText (i) := blockOut
    else
        uncoverText (i) := secretText (i) %%shows non letter chars
    end if
end for

%%main loop
loop
    cls
    for i : 1 .. upper (uncoverText)        %%display current progress
        put uncoverText (i) ..
    end for

    put ""
    put "Enter a letter: " ..
    getch (input)

    %%this will search for the letter, and if its there show it
    for i : 1 .. length (secretText)
        if ord (secretText (i)) = ord (input) then
            uncoverText (i) := input    %%yay shows you it!
        end if
    end for
end loop

%%TO DO LIST
%%have it so you lose after 5 failed attempts
%%have it draw a hang man!
%%make my crappy codeing better


Woot woot! 7 mins to make

ok so you are only using keyboard for this program, but what if you want to use the mouse? all i know is that you have to upload a picture/draw buttons then use buttonwait or mousewhere. But how do you make the program let you click the letters instead of typing in? Sad
MyronMenezes




PostPosted: Sun Jun 17, 2007 8:11 pm   Post subject: Re: hangman help

Yes, a new account created. Well which one is simpler, button presin or mousin?
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  [ 6 Posts ]
Jump to:   


Style:  
Search: