Question: Your task in this lab is to write a program that will move a knight around an empty chess board, leaving behind a trail of
Your task in this lab is to write a program that will move a knight around an empty chess board, leaving behind a trail of increasing integers, ranging from 1 to, hopefully, 64. Here are the specifications for your assignment: 1. The knight will start in first row and first column (list[0][0]). 2. The program will mark squares as they are visited, ranging from 1-64. 3. The program will continue until a complete tour is accomplished (all 64 squares) or the program gets stuck with nowhere to go. 4. The program will print the results, looking something like this (use \t to align the columns):
1 0 21 0 0 14 23 12 20 0 6 9 22 11 0 0 7 2 19 36 15 46 13 24 0 5 8 47 10 37 0 45 0 18 3 16 35 44 25 38 4 31 34 0 42 39 28 0 0 0 17 32 29 26 43 40 0 33 30 0 0 41 0 27 47 squares were visited 5. Use Math.random() to generate the necessary random numbers. 6. You will have an OOP class and a client class. 7. Look on the next page for a suggestion on a way to solve this lab.
Provided OOP template
public class Knight {
private int[][] myBoard;
private static final int[] VERT = {1, 2, 2, 1, -1, -2, -2, -1};
private static final int[] HOT = {-2, -1, 1, 2, 2, 1, -1, -2};
private int myRow;
private int myCol;
private int myCount;
public Knight(){
} public void printBoard() {
}
public void makeMove() { } private boolean isLegalMove(int row, int col){ }
public boolean isStuck(){ } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
