Quellcode durchsuchen

Rafa - haciendo const algunos de los member functions

Rafael Arce Nazario vor 7 Jahren
Ursprung
Commit
65f1307034
2 geänderte Dateien mit 18 neuen und 13 gelöschten Zeilen
  1. 6
    6
      bird.cpp
  2. 12
    7
      bird.h

+ 6
- 6
bird.cpp Datei anzeigen

@@ -46,21 +46,21 @@ Bird::Bird(int s, EyeBrowType eb, QString col, QString eye, QWidget *parent):
46 46
 ///
47 47
 /// Getter for the eyeColor.
48 48
 ///
49
-QString  Bird::getEyeColor(){
49
+QString  Bird::getEyeColor() const {
50 50
     return eColor ;
51 51
 }
52 52
 
53 53
 ///
54 54
 /// Getter for the faceColor.
55 55
 ///
56
-QString  Bird::getFaceColor(){
56
+QString  Bird::getFaceColor() const{
57 57
     return color ;
58 58
 }
59 59
 
60 60
 ///
61 61
 /// Setter for the eyeColor.
62 62
 ///
63
-void  Bird::setEyeColor(QString eye){
63
+void  Bird::setEyeColor(QString eye) {
64 64
     eColor = eye ;
65 65
 }
66 66
 
@@ -74,14 +74,14 @@ void  Bird::setFaceColor(QString col){
74 74
 ///
75 75
 /// Getter for the size.
76 76
 ///
77
-int Bird::getSize(){
77
+int Bird::getSize() const{
78 78
     return size ;
79 79
 }
80 80
 
81 81
 ///
82 82
 /// Getter for the Eyebrow.
83 83
 ///
84
-Bird::EyeBrowType Bird::getEyebrow(){
84
+Bird::EyeBrowType Bird::getEyebrow() const{
85 85
     return eyeBrow ;
86 86
 }
87 87
 
@@ -108,7 +108,7 @@ void Bird::setEyebrow(EyeBrowType eb){
108 108
 ///
109 109
 /// Converts a color specified as string to a Qt::GlobalColor
110 110
 ///
111
-Qt::GlobalColor Bird::getColor(QString color){
111
+Qt::GlobalColor Bird::getColor(QString color) const{
112 112
 
113 113
     if(color=="red")
114 114
         return Qt::red ;

+ 12
- 7
bird.h Datei anzeigen

@@ -29,15 +29,20 @@ public:
29 29
     
30 30
     explicit Bird(QWidget *parent = 0);
31 31
     Bird(int , EyeBrowType , QString , QString, QWidget *parent = 0) ;
32
-    QString  getEyeColor() ;
33
-    QString  getFaceColor() ;
34
-    void  setEyeColor(QString) ;
35
-    void  setFaceColor(QString) ;
36
-    int getSize() ;
37
-    EyeBrowType getEyebrow() ;
32
+
33
+    // getters    
34
+    QString getEyeColor() const;
35
+    QString getFaceColor() const;
36
+    int getSize() const;
37
+    EyeBrowType getEyebrow() const;
38
+    Qt::GlobalColor getColor(QString) const;
39
+
40
+    // setters 
41
+    void setEyeColor(QString) ;
42
+    void setFaceColor(QString) ;
38 43
     void setSize(int) ;
39 44
     void setEyebrow(EyeBrowType) ;
40
-    Qt::GlobalColor getColor(QString) ;
45
+
41 46
 
42 47
     Bird & operator=(Bird &b);
43 48
 signals: