Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a method static Move bestMove9(char [] squares) { } that does the foll

ID: 3844957 • Letter: I

Question

Implement a method static Move bestMove9(char [] squares) { } that does the following: Loops through the array of squares from indexes 1 through 9 looking for a dash ('-'). When a dash is found at index i, return a new Move object with i as the square value and the result of calling evaluateMove9(squares, i) as the value. This is the same evaluateMove9 as in exercise 00299 and it's available to you now: you don't have to write it again. For reference here is the Move class that is available to you for constructing the return value: static class Move { public Move(int square, int value) { this.square = square: this.value = value: } public String toString() { return "(" + square + ", " + value + ")": } public int square;//1 through 9 public int value;//-1, 0, or 1 } The purpose of bestMove9() is to return a Move object with the remaining free square and corresponding value. Essentially to determine what x's last move is (i.e. the 9th move) and what the value of that move is.

Explanation / Answer

static Move bestMove9(char []squares)

   {

   for(int i=1; i<=9; i++)

   {

       if(squares[i]=='-')

       {

              int value = evaluateMove9(squares, i);

              return new Move(i, value);

          

       }

   }

   return null;

   }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote