Computer Science Canada Basic turing- need help checking words (Pleasee help!) |
Author: | jess123 [ Sun Jan 13, 2013 8:41 pm ] |
Post subject: | Basic turing- need help checking words (Pleasee help!) |
What is it you are trying to achieve? I need help checking if a letter in a word is correct, and if it is, add it to a counter and if it isn't add it to another counter but I'm having some trouble. What is the problem you are having? So I have an array of 5 words ( for now) from which the user can guess from. In a loop I ask the user to guess a letter of the word and I need to check if the letter matches the letter in the word and what to do if it doesn't match, but for some reason, its not working. 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) var alpha : array 1..25 of string := init ("a","b","c"...etc) var words : array 1 .. 5 of string := init ("car", "canada", "dog, "maple", "dolphin") right := 0 wrong := 0 randint (random,1,5) loop right := right + 1 wrong := wrong + 1 put "Please make a guess" get guess if random = 1 then words := words (1) if guess = alpha (3) then correct := correct + 1 font.draw (guess,250,50,black) elsif guess = alpha (1) then correct := correct + 1 font.draw (guess,280,50,black) elsif guess = alpha (21) then correct := correct + 1 font.draw (guess,310,50,black) end if if guess not=alpha (3) or guess not=alpha (1) or guessnot= alpha (21) then strike:= strike + 1 end if end loop and so on for every word (Please specify what version of Turing you are using 4.1.1 |
Author: | Panphobia [ Sun Jan 13, 2013 9:46 pm ] |
Post subject: | RE:Basic turing- need help checking words (Pleasee help!) |
I don't think you need that array of strings that holds the alphabet, and what are you doing to remove the character from your word, because I could keep putting a a a a a, and it would increment, also what are you doing to exit the loop where you get the guess? |
Author: | Zren [ Sun Jan 13, 2013 9:48 pm ] | ||
Post subject: | RE:Basic turing- need help checking words (Pleasee help!) | ||
You should probably look into how to iterate through an array (or an array of characters aka a string).
|
Author: | jess123 [ Mon Jan 14, 2013 7:43 pm ] |
Post subject: | Re: RE:Basic turing- need help checking words (Pleasee help!) |
Panphobia @ Sun Jan 13, 2013 9:46 pm wrote: I don't think you need that array of strings that holds the alphabet, and what are you doing to remove the character from your word, because I could keep putting a a a a a, and it would increment, also what are you doing to exit the loop where you get the guess?
Yeah that's where i'm having trouble, i dont know how to remove the character from the word :l |
Author: | Panphobia [ Mon Jan 14, 2013 8:44 pm ] |
Post subject: | RE:Basic turing- need help checking words (Pleasee help!) |
try looking up string manipulation |