Thursday, 12 September 2013

C++: Getters and Setters?

C++: Getters and Setters?

I am attempting to write some code to create getters and setters for the
ID number, first name, last name, midterm score, and final score of the
following data, which is in a text file, in a class i'm writing...
10601 ANDRES HYUN 88 91 94 94 89 84 94 84 89 87 89 91
10611 THU ZECHER 83 79 89 87 88 88 86 81 84 80 89 81
10622 BEVERLEE WAMPOLE 95 92 91 96 99 97 99 89 94 96 90 97
10630 TRUMAN SOVIE 68 73 77 76 72 71 72 77 67 68 72 75
The ID is the first number, first and last name are self explanatory, the
midterm score is the second to last number, and the last number is the
final score. This is my first time using getters and setters and so far I
have...
int getID()const{return ID;}
void setID(int i) {ID=i}
string getFname()const{return Fname;}
void setFname(string f) {Fname = f}
string getLname()const{return Lname;}
void setLname(string l) {Lname = l}
int getMidterm()const{return Midterm;}
void setMidterm(int m) {Midterm=m}
int getFinal()const{return Final;}
void setFinal(int fl) {Final=fl}
Am I on the right track at all? Also, how do I specify that the first
number in the data set is the ID, the first string is the first name,
second string second name, second to last number is Midterm, and last
number is final score?

No comments:

Post a Comment