|
@@ -4,11 +4,11 @@
|
4
|
4
|
![main2.png](images/main2.png)
|
5
|
5
|
![main3.png](images/main3.png)
|
6
|
6
|
|
7
|
|
-[Verano 2016 - Ive]
|
|
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 lab experience you will use `for` loops 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
|
|
13
|
13
|
1. Practice the use of repetition structures to make patterns and tessellations.
|
14
|
14
|
|
|
@@ -16,7 +16,7 @@ One of the advantages of using computer programs is that we can easily implement
|
16
|
16
|
|
17
|
17
|
This laboratory experience is an adaptation of https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
|
18
|
18
|
|
19
|
|
-##Pre-Lab:
|
|
19
|
+## Pre-Lab:
|
20
|
20
|
|
21
|
21
|
Before coming to the laboratory session you should have:
|
22
|
22
|
|
|
@@ -28,15 +28,15 @@ Before coming to the laboratory session you should have:
|
28
|
28
|
|
29
|
29
|
b. adjusting the position of the tessellations,
|
30
|
30
|
|
31
|
|
- c. rotate tessellations.
|
|
31
|
+ c. rotating the tessellations.
|
32
|
32
|
|
33
|
|
-3. Taken the Pre-Lab quiz available in Moodle.
|
|
33
|
+3. Taken the Pre-Lab quiz, available in Moodle.
|
34
|
34
|
|
35
|
35
|
---
|
36
|
36
|
|
37
|
37
|
---
|
38
|
38
|
|
39
|
|
-##Tessellations
|
|
39
|
+## Tessellations
|
40
|
40
|
|
41
|
41
|
A tessellation is a mosaic that is created by repeating a figure to cover the surface without leaving empty spaces or overlapping the figures. A *regular tessellation* is a figure that is made by repeating the same *regular polygon*, like triangles, squares or hexagons. (A regular polygon is a polygon where all sides are congruent and the angles that form the sides are congruent.)
|
42
|
42
|
|
|
@@ -49,7 +49,7 @@ A tessellation is a mosaic that is created by repeating a figure to cover the su
|
49
|
49
|
---
|
50
|
50
|
|
51
|
51
|
|
52
|
|
-##Library
|
|
52
|
+## Library
|
53
|
53
|
|
54
|
54
|
The `Tessellations.pro` project available in `http://bitbucket.org/eip-uprrp/repetitions1-tessellations` contains the `Tessellation` class, which is an abstraction of a tessellation with squares, and the `DrawingWindow` class. The code shown in Figure 2 creates a `DrawingWindow` called `w`, a `Tesselation` called `t` and places the tessellation in position (50,100). Notice that the `addTessellation` method of the `DrawingWindow` class should be invoked to draw the tessellation.
|
55
|
55
|
|
|
@@ -59,7 +59,8 @@ The `Tessellations.pro` project available in `http://bitbucket.org/eip-uprrp/rep
|
59
|
59
|
int main(int argc, char *argv[]) {
|
60
|
60
|
QApplication a(argc, argv);
|
61
|
61
|
|
62
|
|
- DrawingWindow w; // Creates the w object of the DrawingWindow class w.resize(300, 300);
|
|
62
|
+ DrawingWindow w; // Creates the w object of the DrawingWindow class
|
|
63
|
+ w.resize(300, 300);
|
63
|
64
|
w.show();
|
64
|
65
|
|
65
|
66
|
Tessellation t; // Creates the t object of the Tessellation class
|
|
@@ -184,16 +185,16 @@ In today's laboratory experience you will practice the use of nested loops to cr
|
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
|
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
|
187
|
|
187
|
|
-2. The `Tessellations.pro` project contains the `Tessellations` and `DrawingWindow` classes and the `foo` function. Configure the project and run the program. You should see a window similar to the one in Figure 5.
|
|
188
|
+2. The `Tessellations.pro` project contains the `Tessellations` and `DrawingWindow` classes and the `foo` function. Configure the project and run the program by clicking the green arrow in the menu on the left side of the Qt Creator window. You should see a window similar to the one in Figure 5.
|
188
|
189
|
|
189
|
190
|
This figure is created with the `foo` function shown in Figure 4 and explained in Example 1. The `foo` function is invoked from `main()`. In this laboratory experience you will only be making changes to the `main()` function.
|
190
|
191
|
|
191
|
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
|
193
|
|
193
|
194
|
|
194
|
|
-###Exercise 2: Create the `herringbone` function and tessellation
|
|
195
|
+### Exercise 2: Create the `herringbone` function and tessellation
|
195
|
196
|
|
196
|
|
-####Instructions
|
|
197
|
+#### Instructions
|
197
|
198
|
|
198
|
199
|
1. Create a `herringbone` function that produces the tessellation in Figure 8. The size of the window is 400x400. The size of each square in the tessellation is its size by default: 50x50.
|
199
|
200
|
|
|
@@ -209,9 +210,9 @@ In today's laboratory experience you will practice the use of nested loops to cr
|
209
|
210
|
|
210
|
211
|
3. Invoke the `herringbone` function from `main()` and run the program so you can see the tessellation you created.
|
211
|
212
|
|
212
|
|
-###Exercise 3: Create the `zigzag` function and tessellation
|
|
213
|
+### Exercise 3: Create the `zigzag` function and tessellation
|
213
|
214
|
|
214
|
|
-####Instructions
|
|
215
|
+#### Instructions
|
215
|
216
|
|
216
|
217
|
1. Create a `zigzag` function that produces the tessellation in Figure 9.
|
217
|
218
|
|
|
@@ -228,9 +229,9 @@ In today's laboratory experience you will practice the use of nested loops to cr
|
228
|
229
|
3. Invoke the `zigzag` function from `main()` and run the program so you can see the tessellation you created.
|
229
|
230
|
|
230
|
231
|
|
231
|
|
-###Exercise 4: Create the `diamond` function and tessellation
|
|
232
|
+### Exercise 4: Create the `diamond` function and tessellation
|
232
|
233
|
|
233
|
|
-####Instructions
|
|
234
|
+#### Instructions
|
234
|
235
|
|
235
|
236
|
1. Create a `diamond` function that produces the tessellation in Figure 10.
|
236
|
237
|
|
|
@@ -251,14 +252,14 @@ In today's laboratory experience you will practice the use of nested loops to cr
|
251
|
252
|
|
252
|
253
|
---
|
253
|
254
|
|
254
|
|
-##Deliverables
|
|
255
|
+## Deliverables
|
255
|
256
|
|
256
|
|
-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 to document 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, by including the names of the programmers involved, and documenting your program.
|
257
|
258
|
|
258
|
259
|
---
|
259
|
260
|
|
260
|
261
|
---
|
261
|
262
|
|
262
|
|
-##References
|
|
263
|
+## References
|
263
|
264
|
|
264
|
265
|
[1] https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
|