|
@@ -150,7 +150,7 @@ To invoke a method we write the name of the object, followed by a period and the
|
150
|
150
|
`objectName.methodName(arguments);`
|
151
|
151
|
|
152
|
152
|
|
153
|
|
-####Constructors
|
|
153
|
+#### Constructors
|
154
|
154
|
|
155
|
155
|
The first methods of a class that we should understand are the *constructors*. A class can have multiple constructors. One of the constructors will be invoked automatically each time an object of that class is created. In most of the cases, the constructors are used to initialize the values for the object’s attributes. To create objects of a class, we must know which are the constructors of the class.
|
156
|
156
|
|
|
@@ -183,7 +183,7 @@ Have a look at the documentation for the second constructor, `Bird (int, EyeBrow
|
183
|
183
|
`Bird guaraguao(200, Bird::UPSET, "blue", "red");`
|
184
|
184
|
|
185
|
185
|
|
186
|
|
-####Setters (mutators)
|
|
186
|
+#### Setters (mutators)
|
187
|
187
|
|
188
|
188
|
Classes provide methods to modify the values of the attributes of an objected that has been created. These methods are called *setters* or *mutators*. Usually, we declare one setter for each attribute that the class has. The `Bird` class has the following setters:
|
189
|
189
|
|
|
@@ -200,7 +200,7 @@ Bird bobo;
|
200
|
200
|
bobo.setSize(333);
|
201
|
201
|
```
|
202
|
202
|
|
203
|
|
-####Getters (accessors)
|
|
203
|
+#### Getters (accessors)
|
204
|
204
|
|
205
|
205
|
Classes also provide methods to access (get) the value of the attribute of an object. These methods are called *getters* or *accessors*. We usually declare one getter for each attribute a class has. The `Bird` class has the following getters:
|
206
|
206
|
|
|
@@ -216,7 +216,7 @@ Bird piolin;
|
216
|
216
|
cout << piolin.getSize();
|
217
|
217
|
```
|
218
|
218
|
|
219
|
|
-####Other functions or methods you will use in this laboratory experience
|
|
219
|
+#### Other functions or methods you will use in this laboratory experience
|
220
|
220
|
|
221
|
221
|
**MainWindow:** The file `mainwindow.h` contains the declaration of a class called `MainWindow`. The objects that are instances of this class will be able to use the overloaded methods
|
222
|
222
|
|
|
@@ -256,8 +256,8 @@ to generate random numbers in the range [min, max]. The method `randInt` depends
|
256
|
256
|
|
257
|
257
|
---
|
258
|
258
|
|
259
|
|
-## Laboratory session
|
260
|
259
|
|
|
260
|
+## Laboratory session
|
261
|
261
|
|
262
|
262
|
### Exercise 1 - Study the inheritance rules for the *Birds* family
|
263
|
263
|
|
|
@@ -301,9 +301,9 @@ The gene dominance for the eyebrows is given by the following list, ordered from
|
301
|
301
|
|
302
|
302
|
The genes in the eyebrows follow these rules:
|
303
|
303
|
|
304
|
|
- a. If both parents have "angry" eyebrows, the baby will have "unibrow" eyebrows.
|
305
|
|
- b. If both parents have "unibrow" eyebrows, the baby will have "upset" eyebrows.
|
306
|
|
- c. In other cases, the baby will inherit the eyebrows with most dominance from the parent's eyebrows.
|
|
304
|
+ a. If both parents have "angry" eyebrows, the baby will have "unibrow" eyebrows.
|
|
305
|
+ b. If both parents have "unibrow" eyebrows, the baby will have "upset" eyebrows.
|
|
306
|
+ c. In other cases, the baby will inherit the eyebrows with most dominance from the parent's eyebrows.
|
307
|
307
|
|
308
|
308
|
|
309
|
309
|
### Exercise 2 - Study the `main` function
|