|
|
|
|
56
|
6. Display the results on the screen.
|
56
|
6. Display the results on the screen.
|
57
|
|
57
|
|
58
|
|
58
|
|
59
|
-## Objects and methods
|
|
|
|
|
59
|
+## Objects and Methods
|
60
|
|
60
|
|
61
|
The following is the `main` function of a basic program like the one you will be creating. During the laboratory experience you only need to program the `main` function (within the `main.cpp` file). The rest of the files contain functions that implement the functionality of the instructions the robot understands.
|
61
|
The following is the `main` function of a basic program like the one you will be creating. During the laboratory experience you only need to program the `main` function (within the `main.cpp` file). The rest of the files contain functions that implement the functionality of the instructions the robot understands.
|
62
|
|
62
|
|
|
|
|
|
90
|
|
90
|
|
91
|
```
|
91
|
```
|
92
|
|
92
|
|
93
|
-**Figure 2** Example of the `main` function.
|
|
|
|
|
93
|
+**Figure 2** Example of the `main` Function.
|
94
|
|
94
|
|
95
|
---
|
95
|
---
|
96
|
|
96
|
|
|
|
|
|
145
|
|
145
|
|
146
|
## Laboratory Session
|
146
|
## Laboratory Session
|
147
|
|
147
|
|
148
|
-### Exercise 1 - Square grid
|
|
|
|
|
148
|
+### Exercise 1 - Square Grid
|
149
|
|
149
|
|
150
|
Suppose that the robot is currently in the upper left room (northwest) of a **square** space of rooms, i.e. the space contains the same number of rows and columns of rooms (like the one in Figure 1). Design an algorithm that allows the robot to compute the number of rooms that there are in the grid.
|
150
|
Suppose that the robot is currently in the upper left room (northwest) of a **square** space of rooms, i.e. the space contains the same number of rows and columns of rooms (like the one in Figure 1). Design an algorithm that allows the robot to compute the number of rooms that there are in the grid.
|
151
|
|
151
|
|
|
|
|
|
167
|
6. Once you have finished your algorithm, and made it correct and efficient, hand it in using Deliverable 1 in Moodle. On the algorithm's header, write and explain the expression you found about the number of rooms the robot should visit to complete its task for a grid of size $$n \times n$$ (For example, "The robot takes 2x+5 steps, 5 to arrive at the middle and 2n to count the rest").
|
167
|
6. Once you have finished your algorithm, and made it correct and efficient, hand it in using Deliverable 1 in Moodle. On the algorithm's header, write and explain the expression you found about the number of rooms the robot should visit to complete its task for a grid of size $$n \times n$$ (For example, "The robot takes 2x+5 steps, 5 to arrive at the middle and 2n to count the rest").
|
168
|
|
168
|
|
169
|
|
169
|
|
170
|
-### Exercise 2 - Rectangular grid
|
|
|
|
|
170
|
+### Exercise 2 - Rectangular Grid
|
171
|
|
171
|
|
172
|
**Instructions**
|
172
|
**Instructions**
|
173
|
|
173
|
|
|
|
|
|
179
|
|
179
|
|
180
|
4. Hand in the `main.cpp` file with the code to calculate the number of rooms in a rectangular grid using Deliverable 2 in Moodle.
|
180
|
4. Hand in the `main.cpp` file with the code to calculate the number of rooms in a rectangular grid using Deliverable 2 in Moodle.
|
181
|
|
181
|
|
182
|
-### Exercise 3 - Rectangular grid, random position
|
|
|
|
|
182
|
+### Exercise 3 - Rectangular Grid, Random Position
|
183
|
|
183
|
|
184
|
**Instructions**
|
184
|
**Instructions**
|
185
|
|
185
|
|
|
|
|
|
193
|
|
193
|
|
194
|
|
194
|
|
195
|
|
195
|
|
196
|
-### Exercise 4 - Pyramid grid, random position
|
|
|
|
|
196
|
+### Exercise 4 - Pyramid Grid, Random Position
|
197
|
|
197
|
|
198
|
**Instructions**
|
198
|
**Instructions**
|
199
|
|
199
|
|