1
I am developing a game similar to Hangman, where the user has to hit the word chosen by the computer in up to 8 attempts.
The variable mascara
is an array of characters that corresponds to the word the user sees on the screen (which may not display all letters) and the variable palavraSeparada
is a character array that matches the word the user should guess
I’m in doubt in the loop while
below. How do I check if the content of the two arrays is equal?
while(acertou==false&&errou<8){
for(int i=0;i<mascara.length;i++){
System.out.print(mascara[i]);
}
System.out.println("");
letraDigitada = input.nextLine().charAt(0);
for (int i=0;i<palavraSeparada.length;i++){
if (letraDigitada == palavraSeparada[i]){
mascara[i]=letraDigitada;
}
}
}
This is to implement a game of Mastermind (AKA Password)? What is the content of
palavraSeparada
? What is the expected content ofmascara
?– user25930
@Lucasgoeten I have taken the liberty of adding an introductory text to give more context to those who are seeing this issue. If you disagree with something or want to add some more information, just click on the edit link.
– Victor Stafusa