-
Notifications
You must be signed in to change notification settings - Fork 1
/
chocan.h
225 lines (190 loc) · 5.94 KB
/
chocan.h
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
//contains classes for model, member, and provider class
//feel free to make changes as needed
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cctype>
#include <vector>
#include <iomanip>
#include <fstream>
#include <sstream>
using namespace std;
class BST_member;
class BST_provider;
// Inheritance
// Model
// proivder member
class model // @anhho
{
public:
model();
model(const model & copy); //copy constructor, if needed
model(
const string& , //first
const string& , //last
const string& , //address
const string& , //city
const string& , //state
int , //zipcode
const string& //email
);
virtual ~model();
virtual void input();
virtual void display() const;
virtual void read_file(const string& file_name) const;
virtual void update_info();
//input checking
bool valid_email(const string &);
//ChocAn functions
void update_address();
void update_email();
bool update_name();
bool verify_ID(int ID_check); // not done
private:
string first_name;
string last_name;
string address;
string city;
string state;
int zipcode;
string email;
};
class service_list;
class service
{
public:
service();
void create();
void display() const;
int compare_dates(service &to_cmp); // works like strcmp, calling obj is on left, arg is on right
void read_from_disk(ifstream &ifile);
float get_cost();
protected:
// create() helper functions
void enter_date();
void get_service_dir_data();
void get_curr_date();
void capitalize_name();
// error/input checking functions
int parse_date(string date); // turns date strings into nums for comparisons
bool check_date(string m, string d, string y); // checks if date passed is valid
string prep_str(string to_prep); // makes string all lowercase for comparisons
string date_of_service; // MM-DD-YYYY
int code;
string name;
string comments;
float cost;
string current_date; // MM-DD-YYYY HH:MM:SS
};
class service_list
{
public:
service_list();
service_list(const service_list ©);
void add_new_service_record();
void display_all_services();
float total_cost();
void read_from_disk(ifstream &ifile);
int num_services();
private:
vector<service> list;
};
class service_directory
{
public:
service_directory();
// both return -1 on failure
int find_code_by_name(string name);
float find_cost_by_name(string name);
void display_all();
bool is_code_valid(int to_check);
private:
struct entry {
string name;
int code;
float cost;
};
vector<entry> dir;
};
class member: public model // @anhho
{
public:
member();
member(const member & copy); //copy constructor, if needed
member(
const string& , //first
const string& , //last
const string& , //address
const string& , //city
const string& , //state
int , //zipcode
const string& , //email
const bool& , //status
int , //ID
float, //fee
service_list *
);
~member();
void input();
void set_input(int ID, bool status, float fee);
void display(std::ostream&) const;
void update_info();
void read_file(const string &file_name, BST_member& m_tree) const;
bool verify_ID(int ID_check);
bool update_status();
bool display_summary();
void write_reports();
//setters
void set_ID(int ID);
void set_status(bool choice);
void set_service_list();
//getters
float get_fee_mem();
int get_member_ID();
bool get_status_mem();
//operator overloading
bool operator<(const member &to_compare) const; //sorting by ID member
bool operator>(const member &to_compare) const; //sorting by ID member
bool operator>(const int ID_compare) const;
bool operator==(const member &to_compare) const;
bool operator==(const int ID_compare) const;
protected:
bool status_mem; // true: valid | false: invalid
int member_ID;
float fee_mem;
service_list *service_provided;
};
class provider: public model
{
public:
provider();
provider(const provider & copy); //copy constructor, if needed
provider(const string&, const string&,const string &,const string &,const string &, int, const string &, int, int, float, service_list*);
~provider();
void input();
void setInput(int ID, int num, int fee);
void display(std::ostream&) const;
void read(const string& file_name) const;
void update_info();
bool check_service_code(int service_code);
void display_summary() const; //display weekly summary report
void display_directory();
void write_file();
bool verify_provider_ID(int ID);
int get_provider_ID() const;
int get_num_consul() const;
float get_total_fee() const;
void set_ID(int ID);
//operator overloading
bool operator>(const provider & to_compare) const;
bool operator<(const provider & to_compare) const;
bool operator>(const int ID_compare) const;
bool operator==(const provider & to_compare) const;
bool operator==(const int ID_compare) const;
protected:
int num_consul; //number of consultations
float total_fee; //weekly fee
int provider_ID;
service_list *service_provided;
};