-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathTexts.cpp
120 lines (101 loc) · 1.71 KB
/
Texts.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
#pragma once
#include <iostream>
class TTextNode
{
protected:
TTextNode* next;
TTextNode* down;
char c;
int level; //1- строка, 2 - слово, 3 - буква;
public:
TTextNode(int l = 3, char _c = 0);
TTextNode(char* s = 0); // Конструктор принимает слово
TTextNode(const TTextNode& node);
~TTextNode();
TTextNode* GetNext();
TTextNode* GetDown();
char GetC();
int GetLevel();
void SetNext (TTextNode* _next);
void SetDown(TTextNode* _down);
void SetC(char _c);
void SetLevel(int _l);
friend std::ostream& operator << (std::ostream& o, TTextNode& t);
};
//#include "Text.h"
std::ostream& operator<<(std::ostream& o, TTextNode& t)
{
if (t.level == 3)
{
o << t.c;
if (t.next != nullptr)
o << *(t.next);
}
else
{
if (t.down != nullptr)
o << *(t.down);
if (t.next != nullptr)
o << *(t.next);
}
return o;
}
TTextNode::TTextNode(int l, char _c)
{
next = nullptr;
down = nullptr;
c = _c;
level = l;
}
TTextNode::TTextNode(char* s)
{
next = nullptr;
level = 2;
c = 0;
//...
}
TTextNode::TTextNode(const TTextNode& node)
{
next = nullptr;
down = nullptr;
c = node.c;
level = node.level;
}
TTextNode::~TTextNode()
{
}
TTextNode* TTextNode::GetNext()
{
return next;
}
TTextNode* TTextNode::GetDown()
{
return down;
}
char TTextNode::GetC()
{
return c;
}
int TTextNode::GetLevel()
{
return level;
}
void TTextNode::SetNext(TTextNode* _next)
{
next = _next;
}
void TTextNode::SetDown(TTextNode* _down)
{
down = _down;
}
void TTextNode::SetC(char _c)
{
c = _c;
}
void TTextNode::SetLevel(int _l)
{
if (_l >= 1 && _l <= 3)
level = _l;
else
throw - 1;
}