Commit f876a60
Changed files (1)
src
Q9
src/Q9/README.md
@@ -0,0 +1,61 @@
+# Learning Profile for Assignment #2 Question #9
+
+## Name: Mo Khan
+### Student ID: 3431709
+
+1. Problem Statement
+
+ Create a 10x10 matrix as a 2D array. See a sampel array below.
+
+ | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
+ | 0 | [0, 0] | [0, 1] | [0, 2] | [0, 3] | [0, 4] | [0, 5] | [0, 6] | [0, 7] | [0, 8] | [0, 9] |
+ | 1 | [1, 0] | [1, 1] | [1, 2] | [1, 3] | [1, 4] | [1, 5] | [1, 6] | [1, 7] | [1, 8] | [1, 9] |
+ | 2 | [2, 0] | [2, 1] | [2, 2] | [2, 3] | [2, 4] | [2, 5] | [2, 6] | [2, 7] | [2, 8] | [2, 9] |
+ | 3 | [3, 0] | [3, 1] | [3, 2] | [3, 3] | [3, 4] | [3, 5] | [3, 6] | [3, 7] | [3, 8] | [3, 9] |
+ | 4 | [4, 0] | [4, 1] | [4, 2] | [4, 3] | [4, 4] | [4, 5] | [4, 6] | [4, 7] | [4, 8] | [4, 9] |
+ | 5 | [5, 0] | [5, 1] | [5, 2] | [5, 3] | [5, 4] | [5, 5] | [5, 6] | [5, 7] | [5, 8] | [5, 9] |
+ | 6 | [6, 0] | [6, 1] | [6, 2] | [6, 3] | [6, 4] | [6, 5] | [6, 6] | [6, 7] | [6, 8] | [6, 9] |
+ | 7 | [7, 0] | [7, 1] | [7, 2] | [7, 3] | [7, 4] | [7, 5] | [7, 6] | [7, 7] | [7, 8] | [7, 9] |
+ | 8 | [8, 0] | [8, 1] | [8, 2] | [8, 3] | [8, 4] | [8, 5] | [8, 6] | [8, 7] | [8, 8] | [8, 9] |
+ | 9 | [9, 0] | [9, 1] | [9, 2] | [9, 3] | [9, 4] | [9, 5] | [9, 6] | [9, 7] | [9, 8] | [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:
+ 1. up
+ 1. down
+ 1. left
+ 1. right
+ 1. left-up-corner
+ 1. left-down-corner
+ 1. right-up-corner
+ 1. 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:
+ 1. right
+ 2. down
+ 3. 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 `[10 x 10]` 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:
+ 1. stop.
+ 1. print the final slot.
+ 1. print the sequence of random numbers that led R1 to this slot.
+ 1. 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.
+
+1. Description of the Code
+1. Errors and Warnings
+1. Sample Input and Output
+1. Discussion