-
Notifications
You must be signed in to change notification settings - Fork 0
/
Person.cpp
57 lines (48 loc) · 1.33 KB
/
Person.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//============== Moodle adds garbage remove lines from here to top
/* Name: Keita Nonaka
Project 12
This is the source file for the class Person. It contains the code that defines each method of the class.
*/
#include "Person.h"
#include <string>
#include <iostream>
//constructor
Person::Person() {
age = 0;
idNumber = 0;
}
//setters
void Person::setId(int idValue){
idNumber = idValue;
}
void Person::setLastName(string lastNameString){
// copy at most 15 characters from string to lastName
int length = lastNameString.size();
length=(length<15?length:14);
lastNameString.copy( lastName, length );
lastName[ length ] = '\0'; // append null character to lastName
}
void Person::setFirstName(string firstNameString){
// copy at most 10 characters from string to firstName
int length = firstNameString.size();
length=(length<10?length:9);
firstNameString.copy( firstName, length );
firstName[length] = '\0'; // append null character to firstName
}
void Person::setAge(int ageValue){
age = ageValue;
}
//getters
int Person::getId() const{
return idNumber;
}
string Person::getLastName() const{
return lastName;
}
string Person::getFirstName() const{
return firstName;
}
int Person::getAge() const{
return age;
}
//=========remove Moodle garbage from here down=========