Question: Please do this in java [40 marks] Create a 10x10 matrix as a 2D array. See a sample array below. 0 1 2 3 4
![Please do this in java [40 marks] Create a 10x10 matrix](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f5091fa7fe4_68766f5091f87240.jpg)

Please do this in java
[40 marks] Create a 10x10 matrix as a 2D array. See a sample array below.
|
| 0 | 1 | 2 | 3 | 4 | 9 | |
| 0 | R1[0, 0] | [0, 1] | [0, 2] | [0, 3] | [0, 4] | [0, 9] | |
| 1 | [1, 0] | [1, 1] | [1, 2] | [1, 3] | [1, 4] | [1, 9] | |
| 2 | [2, 0] | [2, 1] | [2, 2] | [2, 3] | [2, 4] | [2, 9] | |
| 3 | [3, 0] | [3, 1] | [3, 2] | [3, 3] | [3, 4] | [3, 9] | |
| 4 | [4, 0] | [4, 1] | [4, 2] | [4, 3] | [4, 4] | [4, 9] | |
| 9 | [9, 0] | [9, 1] | [9, 2] | [9, 3] | [9, 4] | [9, 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 - Attributes + int x + 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 getO + public Robot(int x, int y) + public void setX(int x) + public void setY(int y)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
