-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathitem.cpp
More file actions
64 lines (53 loc) · 1016 Bytes
/
item.cpp
File metadata and controls
64 lines (53 loc) · 1016 Bytes
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
#include "item.h"
Item::Item()
{
_text = "";
_done = false;
}
Item::Item(string item)
{
int startf = item.find("false");
int startt = item.find("true");
string str;
if (startf > -1 && startt == -1) // item has false
{
str = item.substr(0, startf - 1);
_done = false;
} else if (startt > -1 && startf == -1) { // item has true
str = item.substr(0, startt - 1);
_done = true;
} else if (startf == -1 && startt == -1) { // item is user input (no true or false)
str = item;
_done = false;
}
_text = str;
}
Item::~Item()
{
// do nothing
}
string Item::text()
{
return _text;
}
void Item::done()
{
_done = true;
}
bool Item::is_done()
{
return _done;
}
string Item::str_tolower(string str)
{
string temp = str;
for (int i = 0; i < temp.size(); ++i)
temp[i] = tolower(temp[i]);
return temp;
}
bool Item::operator==(Item& other)
{
bool text_equal = str_tolower(_text) == str_tolower(other.text());
bool done_equal = _done == other.is_done();
return text_equal && done_equal;
}