r/processing • • Nov 30 '21

Problems with Strings

Post image
0 Upvotes

8 comments sorted by

View all comments

4

u/ParthTatsuki Nov 30 '21

It is unclear what you're trying to do? Are you trying to associate a single key press with the variable dog1? If so, that's not the way to go. The 'key' will give you the key that you pressed, like 'c', not an entire string

1

u/coded-123 Nov 30 '21

No what I’m trying to do is to ask the user a question . For example, I’m building a guessing game; I’ll ask the user what animal image I displayed on the screen and then I compare the user input to my stored variable; if it correct, I type in correct else I’ll end the program

7

u/ParthTatsuki Nov 30 '21

Then what I'd suggest is start by having a blank string, everytime the user presses a key, you append the key to the string. If the key pressed is the "enter" key, you compare the string to the variable and display correct or incorrect. That's the easy way to do it. There may be better ways to do it but it's one of the simplest to start with.