-
Notifications
You must be signed in to change notification settings - Fork 1
/
member.cpp
162 lines (133 loc) · 3.71 KB
/
member.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include "person.h"
/* ------ Constructors ------ */
// Default Constructor
member::member()
:current_member(true)
{
}
// Constructor with Args
member::member(string set_name,
int set_ID,
string set_street,
string set_city,
string set_state,
int set_zip,
bool set_current_member)
: person(set_name,
set_ID,
set_street,
set_city,
set_state,
set_zip),
current_member(set_current_member)
{
}
/* ------ Member Functions ------ */
// Display the derived member information in a formatted view -
// Used for general display purposes. Should always return true as of current.
bool member::display_member()
{
if(person::display_person())
{
cout<< "Valid Member : ";
(current_member) ? cout << "Yes\n": cout << "No\n";
return true;
}
return false;
}
// Display enumerated derived member information - Used by Mack for editing purposes
// Calls base class display_person_edit before outputting inhereted class information.
// Should always return true as of current.
bool member::display_member_edit()
{
if( person::display_person_edit()){
cout<< "[7] Valid Member : ";
(current_member) ? cout << "Yes\n": cout << "No\n";
}
return true;
}
// Copy current member information into the passed in member object
// Calls base class edit, then edits the derived class information. Returns
// true always as of current.
bool member::copy(member & copy_to)
{
person::copy(copy_to);
copy_to.current_member = current_member;
return true;
}
// Alters any found non-zero values from the edit_from object into
// the current member. Currently always returns true
bool member::edit(member & edit_from)
{
person::edit(edit_from);
current_member = edit_from.current_member;
return true;
}
// Checks if the member status. Returns true if current.
bool member::validate()
{
return current_member;
}
// Saves the member information to the ofstream 'write' variable.
// Returns true if the superclass save_info is successful, the member
// information is written, and the provider list is written. Otherwise
// returns false.
bool member::save_member(ofstream & write)
{
if(person::save_info(write))
{
write << current_member << "\n";
for(it = services.begin(); it != services.end(); ++it){
it->save(write);
}
return true;
}
return false;
}
// Loads the member information from the file 'load' into the current
// member. First calls the superclass load_info, then copies data from
// 'load' into its own members, then needs to call load_person_service_
// record function to finish the load. Returns true if successful, false
// if something went wrong.
bool member::load_member(ifstream & load)
{
if(person::load_info(load))
{
load >> current_member;
load.ignore(100, '\n');
services.clear();
ServiceRecord obj;
while(obj.load(load)){
services.push_back(obj);
}
/*for(it = services.begin(); it != services.end(); ++it){
it ->load(load);
}*/
return true;
}
return false;
}
bool member::member_report(ofstream &write) {
write << "Valid Member : ";
(current_member) ? write<< "Yes\n": write<< "No\n";
if(services.empty()){
write << "No services to display " << "\n";
return false;
}
it = services.begin();
if(person::person_report(write)){
if(!it->weekVerificationWrapper()){
write <<"No services this week " << "\n";
}
for(it = services.begin(); it != services.end(); ++it){
if(it ->weekVerificationWrapper()){
//save_member(write);
it->generateMemberReport(write);
}
}
return true;
}
else{
return false;
}
}