This site requires JavaScript, please enable it in your browser!
Greenfoot back
Newbie
Newbie wrote ...

2015/12/29

String problem

Newbie Newbie

2015/12/29

#
In my current programme I have a class named Subject.class. When the User clicks at it, they have to enter a String which is then saved as a variable and written on the image of the Object that has been clicked on. How can I manage to make sure that the person does not enter the same String for two different Objects without having to create static booleans becoming true for every possible String being entered?
Super_Hippo Super_Hippo

2015/12/29

#
You could have an String ArrayList in your world subclass. Whenever a string is typed in, you check if it is equal to any string in the array and if not, it is then added at the end of this array.
Newbie Newbie

2015/12/31

#
Thank you for the tip, I'll try it out!
You need to login to post a reply.