-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObject.cpp
More file actions
57 lines (46 loc) · 1.17 KB
/
Object.cpp
File metadata and controls
57 lines (46 loc) · 1.17 KB
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
#include "Object.h"
const string &Object::getName() const {
return name;
}
void Object::setName(const string &name) {
Object::name = name;
}
const string &Object::getTag() const {
return tag;
}
void Object::setTag(const string &tag) {
Object::tag = tag;
}
Object::Object() {
name = "";
tag = "";
}
Object::Object(string name, string tag) {
Object::name = name;
Object::tag = tag;
}
bool Object::operator<(const Object &object) const {
return this->getName() < object.getName();
}
void Object::saveFile(ofstream &os) {
os << Object::name << '\n'
<< Object::tag << '\n';
}
void Object::loadFile(ifstream &os) {
os >> name
>> tag;
}
void Object::Show_Status(ostream &os) const {
os << endl;
os << Color::Blue << "=======Object=======" << Color::Default << '\n'
<< "Name: " << Color::Yellow << Object::getName() << '\n' << Color::Default
<< Color::Blue << "====================" << Color::Default << '\n'
<< endl;
}
ostream &operator<<(ostream &os, Object *item) {
if (item == nullptr)
os << Color::Cyan << "Empty" << Color::Default;
else
item->Show_Status(os);
return os;
}