-
Notifications
You must be signed in to change notification settings - Fork 0
/
Word.h
126 lines (108 loc) · 2.58 KB
/
Word.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
#ifndef DEF_WORD
#define DEF_WORD
#include <iostream>
#include <fstream>
using namespace std;
class Word {
private:
string word; // tu vung
string type; // loai tu
string mean; // nghia tu
string example; // vi du
public:
Word(); // Ham dung mac dinh
Word(string dong);
virtual ~Word(); // Ham huy
string getWord(); // Lay tu vung
string getType(); // Lay loai tu
string getMean(); // Lay nghia tu
string getExample(); // Lay vi du
void setWord(string m); // Tao tu vung
void setType(string m); // Tao loai tu
void setMean(string m); // Tao nghia tu
void setExample(string m); // Tao vi du
const Word &operator = (const Word &m); // Da nang hoa toan tu =
friend ostream &operator << (ostream &out , const Word &w); // Hien thi thong tin chi tiet tu vung
};
Word::Word(){
this->word = "";
this->example = "";
this->type = "";
this->mean = "";
}
Word::Word(string dong){
int i, pos;
i = 0;
// word/type/mean/example;
// tach tu
string word = "";
while (dong[i] != '/') word += dong[i++];
i++;
// init word in class Word
this->word = word;
// tach loai tu
string type = "";
while (dong[i] != '/') type += dong[i++];
i++;
this->type = type;
// tach nghia
string mean = ""; pos = 0;
while (dong[i] != '/') {
mean += dong[i];
i++;
// nghia moi
if (dong[i] == ';') {
this->mean = mean;
}
}
i++;
// tach vi du
string example = "";
while (dong[i] != '/') {
example += dong[i++];
if (dong[i] == ';') {
this->example = example;
}
}
}
Word::~Word(){}
string Word::getWord(){
return this->word;
}
string Word::getType() {
return this->type;
}
string Word::getMean() {
return this->mean;
}
string Word::getExample() {
return this->example;
}
void Word::setWord(string m) {
this->word = m;
}
void Word::setType(string m) {
this->type = m;
}
void Word::setMean(string m) {
this->mean = m;
}
void Word::setExample(string m) {
this->example = m;
}
const Word &Word::operator = (const Word &m) {
this->word = m.word;
this->type = m.type;
this->mean = m.mean;
this->example = m.example;
return *this;
}
ostream &operator << (ostream &out ,const Word &w){
out << "\n " << char(176) << " " << w.word;
out << endl << " ------" ;
out << "\n " << char(176) << " (" << w.type << "): " << w.mean << "; ";
out << endl << " ------" ;
out << "\n " << char(176) << " " << w.example << endl << endl;
return out;
}
#endif