-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatient.cpp
More file actions
106 lines (89 loc) · 3.09 KB
/
Patient.cpp
File metadata and controls
106 lines (89 loc) · 3.09 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Patient.cpp
*
* Class Description: Models a walk-in clinic patient.
* Class Invariant: Each patient has a unique care card number.
* This care card number must have 10 digits.
* This care card number cannot be modified.
*
* Last modified on: May 2017
* Author: Brendin Green
*/
#include <iostream>
#include <locale> // std::locale, std::isalpha
#include "Patient.h"
using namespace std;
// Default Constructor
// Description: Create a patient with a care card number of "0000000000".
// Postcondition: All data members set to "To be entered",
// except the care card number which is set to "0000000000".
Patient::Patient() {
name = "To be entered";
address = "To be entered";
phone = "To be entered";
email = "To be entered";
careCard = "0000000000";
}
// Parameterized Constructor
// Description: Create a patient with the given care card number.
// Postcondition: If aCareCard does not have 10 digits, then care card is set to "0000000000".
// All other data members set to "To be entered".
Patient::Patient(string aCareCard){
name = "To be entered";
address = "To be entered";
phone = "To be entered";
email = "To be entered";
careCard = (aCareCard.length() != 10) ? "0000000000" : aCareCard;
}
// Getters and setters
// Description: Returns patient's name.
string Patient::getName() const {
return name;
}
// Description: Returns patient's address.
string Patient::getAddress() const {
return address;
}
// Description: Returns patient's phone number.
string Patient::getPhone() const {
return phone;
}
// Description: Returns patient's email.
string Patient::getEmail() const {
return email;
}
// Description: Returns patient's care card number.
string Patient::getCareCard() const {
return careCard;
}
// Description: Sets the patient's name.
void Patient::setName(const string aName) {
name = aName;
}
// Description: Sets the patient's address.
void Patient::setAddress(const string anAddress) {
address = anAddress;
}
// Description: Sets the patient's phone number.
void Patient::setPhone(const string aPhone) {
phone = aPhone;
}
// Description: Sets the patient's email.
void Patient::setEmail(const string anEmail) {
email = anEmail;
}
// Overloaded Operators
// Description: Comparison operator. Compares "this" Patient object with "rhs" Patient object.
// Returns true if both Patient objects have the same care card number.
bool Patient::operator==(const Patient & rhs) {
return getCareCard() == rhs.getCareCard();
}
// Description: Greater than operator. Compares "this" Patient object with "rhs" Patient object.
// Returns true if the care card number of "this" Patient object is > the care card number of "rhs" Patient object.
bool Patient::operator>(const Patient & rhs) {
return getCareCard() > rhs.getCareCard();
}
// Description: Prints the content of "this" patient.
void Patient::printPatient(){
cout << getCareCard() << ", Patient: " << getName() << ", " << getAddress() << ", " << getPhone() << ", " << getEmail() << endl;
}