Question: Java programming [40 marks] Create a 10x10 matrix as a 2D array. See a sample array below. 0 4 9 0 R1[0, 0] [0, 1]
Java programming
![Java programming [40 marks] Create a 10x10 matrix as a 2D array.](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66da8182196a0_03366da818185f4c.jpg)
![See a sample array below. 0 4 9 0 R1[0, 0] [0,](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66da8182e2549_03466da818261029.jpg)
[40 marks] Create a 10x10 matrix as a 2D array. See a sample array below. 0 4 9 0 R1[0, 0] [0, 1] [0, 2] [0, 3] [0, 4][o,9] 2 [2,0] [2, 1] [2, 2] [2, 3] 2,4][2,9] Assume that a robot is placed in position [0, 0]. Now randomly generate a move. The move could take the robot to one of the eight possible adjacent slots - (up, down, left, right, left-up- corner, left-down-corner, right-up-corner, and right-down-corner]- these slots are represented by (1, 2, 3, 4,5,6,7, 8). However, at [0, 0], the robot only has three possible slots to move to- right, down, right-down-corner Create another robot called R2 and place it on [9, 9] Now randomly generate an integer in the range of [1 to 8]. This first random integer corresponds to a possible move for Robot R1. If the move is valid, then move R1 to its new slot. A move is invalid if it takes the robot out of bounds of the [10x10] matrix. If the move is invalid, then keep generating random integers until a valid move is found. Repeat this procedure for the second Robot R2 If both R1 and R2 are in the same slot, then stop, print the final slot, print the sequence of random numbers that led R1 to this slot, and the print the sequence of random numbers that led R2 to the same slot. Implement this program with a Robot class and a MovingRobot subclass. Robot a Attributes + int X + int y + public static final int DOWN + public static final int LEFT +public static final int LEFT_DOWN CORNER +public static final int LEFT_UP CORNER + public static final int RIGHT +public static final int RIGHT DOWN CORNER + public static final int RIGHT UP CORNER + public static final int UP Operations + public int getXO + public int getYO +public Robot(int x, int y) +public void setX(int x) +public void setY(int y) MovingRobot a Attributes +ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
