-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppointment.cpp
190 lines (165 loc) · 4.27 KB
/
Appointment.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
#include"Appointment.h"
void Appointment:: fr() {
date.setIfBusyPeriod(getStartTime(), getEndTime(), 0);
if (name.c_str() != nullptr) {
name.deleteStr();
}
size_t size = comments.getSize();
if (comments.c_str() != nullptr) {
comments.deleteStr();
}
}
void Appointment:: copyFrom(const Appointment& other) {
{
if (checkRow(other.getComments()) && checkRow(other.getName()) && other.getDate().validDate() && other.getStartTime().isValidTime() && other.getEndTime().isValidTime()) {
this->setComments(other.getComments());
this->setName(other.getName());
this->setDate(other.getDate());
this->setStartTime(other.getStartTime());
this->setEndTime(other.getEndTime());
this->date.setIfBusyPeriod(this->getStartTime(), this->getEndTime(), 1);
}
}
}
Appointment::Appointment() {}
String Appointment::getComments() const
{
return comments.c_str();
}
String Appointment::getName() const
{
return name.c_str();
}
Time& Appointment::getStartTime() const
{
return startTime;
}
Time& Appointment::getEndTime() const
{
return endTime;
}
Date& Appointment::getDate() const
{
return date;
}
Time& Appointment::getDuration() const
{
return (getStartTime().difference(getEndTime()));
}
void Appointment::setDate(const Date& date)
{
this->date = date;
}
void Appointment::setName(const String name)
{
if (checkRow(name)) {
this->name = name;
}
}
void Appointment::setComments(const String com)
{
if (checkRow(com)) {
this->comments = com;
}
}
void Appointment::setAppointment(const String name,const String comments, const Date& newDate, const Time& beginning, const Time& ending)
{
if (checkRow(comments) && checkRow(name) && newDate.validDate() && beginning.isValidTime() && ending.isValidTime()) {
this->setName(name);
this->setComments(comments);
this->setDate(newDate);
this->setStartTime(beginning);
this->setEndTime(ending);
this->date.setIfBusyPeriod(this->getStartTime(), this->getEndTime(), 1);
}
}
void Appointment::setStartTime(const Time& newTime)
{
startTime = newTime;
}
void Appointment::setEndTime(const Time& newTime)
{
endTime = newTime;
}
void Appointment::operator=(const Appointment& other)
{
if (checkRow(other.getComments()) && checkRow(other.getName()) && other.getDate().validDate() && other.getStartTime().isValidTime() && other.getEndTime().isValidTime()) {
if (this != &other) {
this->setComments(other.getComments());
this->setName(other.getName());
this->setDate(other.getDate());
this->setStartTime(other.getStartTime());
this->setEndTime(other.getEndTime());
this->date.setIfBusyPeriod(this->getStartTime(), this->getEndTime(), 1);
}
}
}
bool Appointment::compareNames(const String toCompare) const
{
return name.compareStrings(toCompare);
}
bool Appointment::compareComments(const String toCompare) const
{
return comments.compareStrings(toCompare);
}
bool Appointment::hasSameName(const String toCompare) const
{
return comments.hasSameString(toCompare);
}
bool Appointment::hasSameComment(const String toCompare) const
{
return (name.hasSameString(toCompare));
}
bool Appointment::compareAppointment(const Appointment& app)const {
if (this->hasSameName(app.getName()) == 0) {
return 0;
}
if (this->hasSameComment(app.getComments()) != 1) {
return 0;
}
if (this->date.compareNoTime(app.getDate()) != 0) {
return 0;
}
if (this->getStartTime().compare(app.getStartTime()) != 0) {
return 0;
}
if (this->getEndTime().compare(app.getEndTime()) != 0) {
return 0;
}
return 1;
}
void Appointment::printName() const
{
size_t size = name.getSize();
for (size_t i = 0; i < size+1; i++) {
std::cout << name[i];
}
std::cout << std::endl;
}
void Appointment::printComments() const
{
size_t sizeText = comments.getSize();
for (size_t i = 0; i < sizeText+1; i++) {
for (size_t j = 0; j <= sizeText; j++) {
std::cout << comments[i];
}
std::cout << std::endl;
}
std::cout << std::endl;
}
void Appointment::printAppointment() const
{
printName();
getDate().printNoTime();
getStartTime().print();
getEndTime().print();
printComments();
}
void Appointment::deleteAppontment()
{
fr();
}
Appointment::~Appointment()
{
fr();
}