• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help with mastermind game app.

Hey I have been building building a mastermind game app for a while now, in the app the user inputs 4 numbers, there guess is then checked against 4 randomly generated numbers, then with letters above each four of there numbers they are shown what number is correct what is wrong and what number is in the code but in the wrong place. ("V" = Right, "S" = in the wrong place, "X" = wrong)

And now I've run to a problem I just can't solve by my self.

I'm working on the class that will the users input (a 4 letter number) I've gotten as far as it showing you what numbers are, right and wrong, plus if they are in the code but in the wrong place.
The problem I'm having is that the S to symbolise it is in the wrong place appears even if the number that's it is saying is in there somewhere has been found correctly.

e.g. [X-S-V-X]
[1-2-2-3]

As you can see the first 2 is shown that it needs to be in the right place, this is referring to the position next to it, what I want to do is make it so that it checks if the 2 has been found an no longer shows it as needing to be changed.

[X-X-V-X]
[1-2-2-3] <--- it would look more like this.


I'm using something like this to check each of the users numbers that they have guessed:

[HIGH]if (Arrays.asList(home_list).contains(guess_list[0])) {
if (code.int1 == Level_select.value1) {

X1.setText("V");

guess.c1 = GuessStatus.V;
}else
{
X1.setText("S");

guess.c1 = GuessStatus.S;

}else
{
X1.setText("X");

guess.c1 = GuessStatus.X;
}});[/HIGH]What I want is if anyone knows how I can do what I described above because I'm really struggling with this problem, thank you!
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones