#Trying to understand why I can't compile the java file.. has to do with an error I can't figure out

1 messages ยท Page 1 of 1 (latest)

ember iceBOT
#

<@&987246399047479336> please have a look, thanks.

ember iceBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

s {
public static void main(String[] args) {
// create a new chess board
Board board = new Board();

    // create a new scanner object to read user input
    Scanner scanner = new Scanner(System.in);
    
    // create an array list to store the moves made by the players
    ArrayList<String> moves = new ArrayList<>();
    
    // initialize the current player as white
    String currentPlayer = "white";
    
    // loop until the game is over
    while (!board.isGameOver()) {
        // print the current state of the board
        System.out.println(board);
        
        // prompt the current player for their move
        System.out.print("Enter your move: ");
        String move = scanner.nextLine();
        
        // validate and make the move
        if (board.isValidMove(move, currentPlayer)) {
            board.makeMove(move);
            moves.add(move);
            
            // switch to the other player
            if (currentPlayer.equals("white")) {
                currentPlayer = "black";
            } else {
                currentPlayer = "white";
            }
        } else {
            System.out.println("Invalid move. Try again.");
        }
    }
    
    // print the final state of the board and the moves made by both players
    System.out.println(board);
    System.out.println("Moves: " + moves);
}

}

The error message I get is:

PlayChess.java:4: error: class PlayChes does not have a main method with appropriate signature
public class PlayChes{
^
1 error