-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.cpp
273 lines (234 loc) · 5.59 KB
/
class.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
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
//Arafat Iqbal
//Functions for my classes.
//All functions stored in the class.h file.
#include "class.h"
//Info Functions
info::info():category(nullptr),number(0)
{
}
info::info(char * category,int number)
{
this->category = new char[strlen(category)+1];
strcpy(this->category,category);
this->number = number;
}
info::info(const info & to_copy)
{
category = new char[strlen(to_copy.category)+1];
strcpy(category,to_copy.category);
number = to_copy.number;
}
info::~info()
{
delete [] category;
category = NULL;
number = 0;
}
//getters
char * info:: get_category()
{
return this->category;
}
int info:: get_number()
{
return this->number;
}
bool info::operator <(const info & p) const
{
return strcmp(this->category,p.category);
}
istream & operator >> (istream & go, info & p)
{
p.insert(go);
return go;
}
ostream & operator << (ostream & out, info & p)
{
p.display(out);
return out;
}
//Display Function
void info::display()
{
cout << "\tCategory: " << this->category << endl;
cout << "\tCategory Number: " << this->number << endl;
return;
}
void info::insert()
{
}
//Zoom Functions
zoom::zoom():date(nullptr),url(nullptr)
{
}
zoom::zoom(char * category,int number,char * date,char * url):info(category,number)
{
this->date = new char[strlen(date)+1];
strcpy(this->date,date);
this->url = new char[strlen(url)+1];
strcpy(this->url,url);
}
zoom::zoom(const zoom & to_copy):info(to_copy)
{
date = new char[strlen(to_copy.date)+1];
strcpy(date,to_copy.date);
url = new char[strlen(to_copy.url)+1];
strcpy(url,to_copy.url);
}
zoom::~zoom()
{
delete date;
date = NULL;
delete url;
url = NULL;
}
//Zoom Display Function
void zoom::display(ostream& out)
{
info::display();
out << "\tThe Date of Meeting: " << this->date << endl;
out << "\tMeeting URL: " << this->url << endl;
return;
}
//Zoom insert Function
void zoom::insert(istream & go)
{
char the_category[MAX];
char the_date[MAX];
char the_url[MAX];
int num = 0;
cout << "What's the Category?: " << endl;
go.get(the_category,100,'\n');
go.ignore(100,'\n');
this->category = new char[strlen(the_category) + 1];
strcpy(this->category,the_category);
cout << "Enter The Category Number: " << endl;
go >> num;
go.ignore();
this->number = num;
cout << "Enter In The Date of Meeting: " << endl;
go.get(the_date,100,'\n');
go.ignore(100,'\n');
this->date = new char[strlen(the_date) + 1];
strcpy(this->date,the_date);
cout << "Enter In The Meeting URL: " << endl;
go.get(the_url,100,'\n');
go.ignore(100, '\n');
this->url = new char[strlen(the_url) + 1];
strcpy(this->url,the_url);
ofstream file;
file.open("info.txt");
file<<1<<','<< this->category<<','<<this->number<<','<<this->date<<','<<this->url<<endl;
file.close();
}
//Homework Functions
project::project():assignment(nullptr)
{
}
project::project(char * category,int number,char * assignment):info(category,number)
{
this->assignment = new char[strlen(assignment)+1];
strcpy(this->assignment,assignment);
}
project::project(const project & to_copy):info(to_copy)
{
assignment = new char[strlen(to_copy.assignment)+1];
strcpy(assignment,to_copy.assignment);
}
project::~project()
{
delete assignment;
assignment = NULL;
}
//Display Homework
void project::display(ostream & out)
{
info::display();
out << "\tThe Assignment Description: " << this->assignment << endl;
return;
}
//Insert Homework
void project::insert(istream & go)
{
char the_category[MAX];
char the_assignment[MAX];
int num = 0;
cout << "What's the Category?: " << endl;
go.get(the_category,100,'\n');
go.ignore(100,'\n');
this->category = new char[strlen(the_category) + 1];
strcpy(this->category,the_category);
cout << "Enter The Category Number: " << endl;
go >> num;
go.ignore();
this->number = num;
cout << "Enter In The Assignment Description: " << endl;
go.get(the_assignment,100,'\n');
go.ignore(100,'\n');
this->assignment = new char[strlen(the_assignment) + 1];
strcpy(this->assignment,the_assignment);
ofstream file;
file.open("info.txt",ios::app);
file<<2<<','<< this->category<<','<<this->number<<','<<this->assignment<<endl;
file.close();
}
//Lecture functions
lecture::lecture():topic(nullptr),length(0)
{
}
lecture::lecture(char * category,int number, char * topic,int length):info(category,number)
{
this->topic = new char[strlen(topic)+1];
strcpy(this->topic,topic);
this->length = length;
}
lecture::lecture(const lecture & to_copy):info(to_copy)
{
topic = new char[strlen(to_copy.topic)+1];
strcpy(topic,to_copy.topic);
length = to_copy.length;
}
lecture::~lecture()
{
delete topic;
topic = NULL;
length = 0;
}
//Lecture Display function
void lecture::display(ostream & out)
{
info::display();
out << "\tThe Lecture Topic: " << this->topic << endl;
out << "\tThe Length Of Video: " << this->length << endl;
return;
}
//Lecture Insert Function
void lecture::insert(istream & go)
{
char the_category[MAX];
char the_topic[MAX];
int num = 0;
int len = 0;
cout << "What's the Category?: " << endl;
go.get(the_category,100,'\n');
go.ignore(100,'\n');
this->category = new char[strlen(the_category) + 1];
strcpy(this->category,the_category);
cout << "Enter The Category Number: " << endl;
go >> num;
go.ignore();
this->number = num;
cout << "Enter In The Lecture Topic " << endl;
go.get(the_topic,100,'\n');
go.ignore(100,'\n');
this->topic = new char[strlen(the_topic) + 1];
strcpy(this->topic,the_topic);
cout << "Enter The Lecture Video Length: " << endl;
go >> len;
go.ignore();
this->length = len;
ofstream file;
file.open("info.txt");
file<<2<<','<< this->category<<','<<this->number<<','<<this->topic<<','<<this->length<<endl;
file.close();
}