|
@@ -24,17 +24,17 @@ Before you get to the laboratory you should have:
|
24
|
24
|
|
25
|
25
|
1. Reviewed the following concepts related to decision structures:
|
26
|
26
|
|
27
|
|
- a. Logical operators
|
|
27
|
+ a. Logical operators
|
28
|
28
|
|
29
|
|
- b. `if`, `else`, `else if`.
|
|
29
|
+ b. `if`, `else`, `else if`.
|
30
|
30
|
|
31
|
31
|
2. Reviewed the following concepts related to objects and classes in C++:
|
32
|
32
|
|
33
|
|
- a. the creation of objects of a class.
|
|
33
|
+ a. the creation of objects of a class.
|
34
|
34
|
|
35
|
|
- b. using the "getter" methods to access an object's attributes.
|
|
35
|
+ b. using the "getter" methods to access an object's attributes.
|
36
|
36
|
|
37
|
|
- c. using the "setter" methods to modify an object's attributes.
|
|
37
|
+ c. using the "setter" methods to modify an object's attributes.
|
38
|
38
|
|
39
|
39
|
3. Studied the documentation for the `Bird` class available in [this link](doc/en/html/index.html).
|
40
|
40
|
|
|
@@ -67,27 +67,26 @@ The following is the skeleton of the declaration of a class:
|
67
|
67
|
|
68
|
68
|
---
|
69
|
69
|
|
70
|
|
-```
|
71
|
|
- class ClassName
|
72
|
|
- {
|
73
|
|
- // Declarations
|
74
|
|
-
|
75
|
|
- private:
|
76
|
|
- // Declaration of variables or attributes
|
77
|
|
- // and prototype member functions
|
78
|
|
- // that are private for this class
|
79
|
|
-
|
80
|
|
- type privateVar
|
81
|
|
- type nameOfPrivateMemFunc(type of the parameters);
|
82
|
|
-
|
83
|
|
- public:
|
84
|
|
- // Declarations of attributes
|
85
|
|
- // and prototypes of method functions
|
86
|
|
- // that are public for the entire program
|
87
|
|
-
|
88
|
|
- type publicVar;
|
89
|
|
- type nameOfPublicMemFunc(type of the parameters);
|
90
|
|
- };
|
|
70
|
+```cpp
|
|
71
|
+class ClassName {
|
|
72
|
+ // Declarations
|
|
73
|
+
|
|
74
|
+private:
|
|
75
|
+ // Declaration of variables or attributes
|
|
76
|
+ // and prototype member functions
|
|
77
|
+ // that are private for this class
|
|
78
|
+
|
|
79
|
+ type privateVar
|
|
80
|
+ type nameOfPrivateMemFunc(type of the parameters);
|
|
81
|
+
|
|
82
|
+public:
|
|
83
|
+ // Declarations of attributes
|
|
84
|
+ // and prototypes of method functions
|
|
85
|
+ // that are public for the entire program
|
|
86
|
+
|
|
87
|
+ type publicVar;
|
|
88
|
+ type nameOfPublicMemFunc(type of the parameters);
|
|
89
|
+};
|
91
|
90
|
```
|
92
|
91
|
---
|
93
|
92
|
|
|
@@ -108,9 +107,8 @@ The methods of a class determine the actions that we can take on the objects of
|
108
|
107
|
---
|
109
|
108
|
|
110
|
109
|
|
111
|
|
-```
|
112
|
|
-class Bird : public QWidget
|
113
|
|
-{
|
|
110
|
+```cpp
|
|
111
|
+class Bird : public QWidget {
|
114
|
112
|
.
|
115
|
113
|
.
|
116
|
114
|
.
|
|
@@ -197,7 +195,7 @@ Classes provide methods to modify the values of the attributes of an objected th
|
197
|
195
|
|
198
|
196
|
You can see the method's declarations in Figure 1 and in the `Bird` class declaration in `bird.h`, and the implementation of the some of the methods in `bird.cpp`. The code in the following example creates the object `bobo` of the `Bird` class and then changes its size to 333.
|
199
|
197
|
|
200
|
|
-```
|
|
198
|
+```cpp
|
201
|
199
|
Bird bobo;
|
202
|
200
|
bobo.setSize(333);
|
203
|
201
|
```
|
|
@@ -213,7 +211,7 @@ Classes also provide methods to access (get) the value of the attribute of an ob
|
213
|
211
|
|
214
|
212
|
You can see the declarations of the methods in Figure 1 and in the `Bird` class declaration in `bird.h`, and the implementations of some of the methods in `bird.cpp`. The code in the following example creates the object `piolin` of the `Bird` class and prints its size:
|
215
|
213
|
|
216
|
|
-```
|
|
214
|
+```cpp
|
217
|
215
|
Bird piolin;
|
218
|
216
|
cout << piolin.getSize();
|
219
|
217
|
```
|
|
@@ -228,7 +226,7 @@ cout << piolin.getSize();
|
228
|
226
|
|
229
|
227
|
that will add to the screen a drawing of an object of the `Bird` class that is received as an argument. The code in the following example creates an object `w` of the `MainWindow` class, creates an object `zumbador` of the `Bird` class and adds it in the position (200,200) on the screen `w` using the first method.
|
230
|
228
|
|
231
|
|
-```
|
|
229
|
+```cpp
|
232
|
230
|
MainWindow w;
|
233
|
231
|
Bird zumbador;
|
234
|
232
|
w.addBird(200,200,zumbador);
|
|
@@ -328,8 +326,9 @@ The genes in the eyebrows follow these rules:
|
328
|
326
|
|
329
|
327
|
1. Load the project `BirthOfABird` into `QtCreator`. There are two ways to do this:
|
330
|
328
|
|
331
|
|
- * Using the virtual machine: Double click the file `BirthOfABird.pro` located in the folder `/home/eip/labs/selections-birthofabird` of your virtual machine.
|
332
|
|
- * Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/selections-birthofabird` to download the folder `selections-birthofabird` from `Bitbucket`. Double click the file `BirthOfABird.pro` located in the folder that you downloaded to your computer.
|
|
329
|
+ * Using the virtual machine: Double click the file `BirthOfABird.pro` located in the folder `/home/eip/labs/selections-birthofabird` of your virtual machine.
|
|
330
|
+
|
|
331
|
+ * Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/selections-birthofabird` to download the folder `selections-birthofabird` from `Bitbucket`. Double click the file `BirthOfABird.pro` located in the folder that you downloaded to your computer.
|
333
|
332
|
|
334
|
333
|
2. Configure the project.
|
335
|
334
|
|
|
@@ -343,7 +342,6 @@ The genes in the eyebrows follow these rules:
|
343
|
342
|
|
344
|
343
|
---
|
345
|
344
|
|
346
|
|
-
|
347
|
345
|
![funcionMain.png](images/funcionMain.png)
|
348
|
346
|
|
349
|
347
|
**Figure 2.** `Main` function.
|