|
|
|
|
6
|
|
6
|
|
7
|
[Verano 2016 - Ive - Coralys]
|
7
|
[Verano 2016 - Ive - Coralys]
|
8
|
|
8
|
|
9
|
-One of the advantages of using computer programs is that we can easily implement repetitive tasks. Structures such as the `for`, `while`, and `do-while` allow us to repeat a block of instructions as many times as needed. In this laboratory experience you will use `for` loops to produce patterns and mosaics.
|
|
|
|
|
9
|
+One of the advantages of using computer programs is that we can easily implement repetitive tasks. Structures such as the `for`, `while`, and `do-while` allow us to repeat a block of instructions as many times as needed. In this laboratory experience, you will use `for` loops to produce patterns and mosaics.
|
10
|
|
10
|
|
11
|
## Objectives:
|
11
|
## Objectives:
|
12
|
|
12
|
|
|
|
|
|
44
|
|
44
|
|
45
|
![figure1.gif](images/figure1.gif)
|
45
|
![figure1.gif](images/figure1.gif)
|
46
|
|
46
|
|
47
|
-**Figure 1** - The only regular tessellations possible obtained using triangles, squares and hexagons.
|
|
|
|
|
47
|
+**Figure 1.** The only regular tessellations possible obtained using triangles, squares and hexagons.
|
48
|
|
48
|
|
49
|
---
|
49
|
---
|
50
|
|
50
|
|
|
|
|
|
172
|
---
|
172
|
---
|
173
|
|
173
|
|
174
|
|
174
|
|
175
|
-## Laboratory Session
|
|
|
|
|
175
|
+## Laboratory Session:
|
176
|
|
176
|
|
177
|
In today's laboratory experience you will practice the use of nested loops to create different tessellations.
|
177
|
In today's laboratory experience you will practice the use of nested loops to create different tessellations.
|
178
|
|
178
|
|
179
|
-### Exercise 1 - Study the loop that produces tessellations
|
|
|
|
|
179
|
+### Exercise 1 - Study the Loop that Produces Tessellations
|
180
|
|
180
|
|
181
|
#### Instructions
|
181
|
#### Instructions
|
182
|
|
182
|
|
183
|
-1. Load the project `Tessellations` into `QtCreator`. There are two ways to do this:
|
|
|
|
|
183
|
+1. Load the project `Tessellations` into `QtCreator`. There are two ways to do this:
|
184
|
|
184
|
|
185
|
* Using the virtual machine: Double click the file `Tessellations.pro` located in the folder `/home/eip/labs/repetitions-tessellations` of your virtual machine.
|
185
|
* Using the virtual machine: Double click the file `Tessellations.pro` located in the folder `/home/eip/labs/repetitions-tessellations` of your virtual machine.
|
186
|
* Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/repetitions-tessellations` to download the folder `repetitions-tessellations` from `Bitbucket`. Double click the file `Tessellations.pro` located in the folder that you downloaded to your computer.
|
186
|
* Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/repetitions-tessellations` to download the folder `repetitions-tessellations` from `Bitbucket`. Double click the file `Tessellations.pro` located in the folder that you downloaded to your computer.
|
|
|
|
|
192
|
Study the `foo` function once again and notice the creation of the objects from the `Tessellations` class, the use of the `setRotation` method, and the `move` method to set the tessellation in the desired position. Notice how the instructions in the `for` loop in the function use the loop's counter to determine the square's position and how the rotation's value is incremented. Also notice that you will need to use the `addTessellation` method to add the tessellation to the `w` window.
|
192
|
Study the `foo` function once again and notice the creation of the objects from the `Tessellations` class, the use of the `setRotation` method, and the `move` method to set the tessellation in the desired position. Notice how the instructions in the `for` loop in the function use the loop's counter to determine the square's position and how the rotation's value is incremented. Also notice that you will need to use the `addTessellation` method to add the tessellation to the `w` window.
|
193
|
|
193
|
|
194
|
|
194
|
|
195
|
-### Exercise 2: Create the `herringbone` function and tessellation
|
|
|
|
|
195
|
+### Exercise 2 - Create the `herringbone` Function and Tessellation
|
196
|
|
196
|
|
197
|
#### Instructions
|
197
|
#### Instructions
|
198
|
|
198
|
|
|
|
|
|
206
|
|
206
|
|
207
|
---
|
207
|
---
|
208
|
|
208
|
|
209
|
-2. Comment the **invocation** of the `foo` function.
|
|
|
|
|
209
|
+2. Comment the invocation of the `foo` function.
|
210
|
|
210
|
|
211
|
3. Invoke the `herringbone` function from `main()` and run the program so you can see the tessellation you created.
|
211
|
3. Invoke the `herringbone` function from `main()` and run the program so you can see the tessellation you created.
|
212
|
|
212
|
|
213
|
-### Exercise 3: Create the `zigzag` function and tessellation
|
|
|
|
|
213
|
+### Exercise 3 - Create the `zigzag` Function and Tessellation
|
214
|
|
214
|
|
215
|
#### Instructions
|
215
|
#### Instructions
|
216
|
|
216
|
|
|
|
|
|
229
|
3. Invoke the `zigzag` function from `main()` and run the program so you can see the tessellation you created.
|
229
|
3. Invoke the `zigzag` function from `main()` and run the program so you can see the tessellation you created.
|
230
|
|
230
|
|
231
|
|
231
|
|
232
|
-### Exercise 4: Create the `diamond` function and tessellation
|
|
|
|
|
232
|
+### Exercise 4 - Create the `diamond` Function and Tessellation
|
233
|
|
233
|
|
234
|
#### Instructions
|
234
|
#### Instructions
|
235
|
|
235
|
|
|
|
|
|
254
|
|
254
|
|
255
|
## Deliverables
|
255
|
## Deliverables
|
256
|
|
256
|
|
257
|
-Use "Deliverables" in Moodle to upload the `main.cpp` file that contains the `herringbone`, `zigzag` and `diamond` functions that you created in Exercises 2, 3, and 4. Remember to use good programming techniques, by including the names of the programmers involved, and documenting your program.
|
|
|
|
|
257
|
+Use "Deliverables" in Moodle to upload the `main.cpp` file that contains the `herringbone`, `zigzag` and `diamond` functions that you created in Exercises 2, 3, and 4. Remember to use good programming techniques, include the names of the programmers involved, and document your program.
|
258
|
|
258
|
|
259
|
---
|
259
|
---
|
260
|
|
260
|
|
|
|
|
|
262
|
|
262
|
|
263
|
## References
|
263
|
## References
|
264
|
|
264
|
|
265
|
-[1] https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
|
|
|
|
|
265
|
+[1] https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
|