I have the following code snippet:
import java.util.Random;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import java.io.*;
import java.lang.String;
public class findthewordgame {
static Random random = new Random();
public static String arrayWord () {
String[] wordgame = { //array
"TEA",
"COFFEE",
"BOAT",
"SEA",
"SUN"
};
int idx = random.nextInt(wordgame.length);
String wordChosen = (wordgame[idx]);
//System.out.println(wordChosen); //prints the random word
//System.out.println(scramble(wordChosen));
return (scramble(wordChosen));
}
public static String scramble(String inputString )
{
// Convert string into a simple char array:
char[] a = inputString.toCharArray();
// Scramble the letters using the standard Fisher-Yates shuffle,
for( int i=0 ; i<a.length ; i++ )
{
int j = random.nextInt(a.length);
//shuffle the characters
char temp = a[i];
a[i] = a[j];
a[j] = temp;
}
return new String(a);
}
public static String input() {
Scanner reader = new Scanner(System.in);
System.out.println("Enter the correct answer: ");
String n = reader.next();
return n;
}
public static void verifyWord(String wordChosen, Scanner reader){
boolean answeredCorrectly = false;
int tries = 1;
//String wordChosen = random.nextInt();
String answer = wordChosen;
while (tries>0 && answeredCorrectly == false) {
answer = reader.next();
if (wordChosen == answer) {
System.out.println("You got it right");
answeredCorrectly = true;
}
else if (answer != wordChosen) {
System.out.println("Wrong");
}
}
}
I do not understand when I try to call it on Main it is giving error (see photo).