-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.cpp
More file actions
300 lines (259 loc) · 6.8 KB
/
driver.cpp
File metadata and controls
300 lines (259 loc) · 6.8 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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#include <iostream>
#include "Story.h"
//using namespace std;
int main() {
/*
Word hello("hello");
Word bye("bye");
Word cs240("cStwoforty");
Word gg("gG");
*/
Word like("like");
Word thiss("this");
Story file("input.txt");
//file.show();
//file.save("output.txt");
//file.show();
Paragraph p("I am the best; the end.");
Story f = p + file;
//f.show();
cout << f;
cout << "-----------------------------START---------------------------" << endl;
//f.show();
//cout << file.rest();
//Sentence r("Like this like.");
//Paragraph gg("Hello World to CStwoforty! The robot exclaimed. It was excited to receive a new incoming class of students to teach for the semester. The End.");
//Story p = file + gg;
//p.show();
//cout << p;
//gg.show();
//cout << --f;
/*
hello++;
hello.show();
hello--;
hello.show();
hello + 1;
hello.show();
bye = hello;
bye.show();
++hello;
hello.show();
*/
cout << "----------------------------Sentence-------------------------" << endl;
//Sentence a = like + (thiss + like);
//cout << a;
//a.rest().show();
///a++.show();
//a.show();
//Sentence b = bye + (cs240 + hello);
//b.show();
//Sentence c = a + bye;
//c.show();
//Sentence d = hello + (bye + cs240);
//d.show();
//Sentence e = bye + d;
//e.show();
cout << "---------------------------Paragraph-------------------------" << endl;
//Paragraph x = (like + thiss) + (like + like);
//x.show();
//Story s = x + file;
//s.show();
//x + 1;
//cout << x ;
//cout << ++x;
//cout << --x;
//x.show();
//++x;
//x.show();
//x = x + x;
//x.first().show();
//x++.show();
//x + 1;
//x.show();
//std::cout << x.rest();
//x.show();
//Paragraph z = x + a;
//z--.show();
//z.show();
//sen + para
//Paragraph y = a + x;
//Paragraph q = x + ((bye + hello) + (hello + cs240)); //head is null in paragraph copy constructor
cout << "------------------------------Show---------------------------" << endl;
//y.show();
//q.show();
//std::cout << z.first();
//std::cout << z.rest();
//std::cout << x.rest();
//z.show();
//b--;
//b.show();
//b+1;
//b.show();
//std::cout << b;
//std::cout << b.first();
//std::cout << d.first();
//std::cout << e.rest();
//std::cout << d.rest();
//bye = hello;
//bye.show();
/*
{
// test Word + Word
std::cout << (hello + bye) << std::endl;
// test Word + Sentence
std::cout << (hello + (bye + cs240)) << std::endl;
// test Sentence + Word
std::cout << ((hello + bye) + cs240) << std::endl;
}
{
// test Sentence + Sentence
Paragraph p((hello + cs240) + (bye + cs240));
std::cout << p << std::endl;
// test Sentence + Paragraph
std::cout << (hello + hello) + p << std::endl;
// test Paragraph + Sentence
std::cout << p + (bye + bye) << std::endl;
// test Paragraph + Paragraph
std::cout << p + p << std::endl;
}
//works
{
Story s("input.txt");
Paragraph p((hello + cs240) + (bye + cs240));
// test Paragraph + Story
std::cout << p + s << std::endl;
// test Story + Paragraph
std::cout << s + p << std::endl;
// test Story + Story
std::cout << s + s << std::endl;
}
//works
{
// test postfix ++/--
std::cout << hello << std::endl;
hello++;
std::cout << hello << std::endl;
hello--;
std::cout << hello << std::endl;
Sentence s(hello + cs240);
s++;
std::cout << s << std::endl;
s--;
std::cout << s << std::endl;
Paragraph p(s + (bye + cs240));
p++;
std::cout << p << std::endl;
p--;
std::cout << p << std::endl;
Story story("input.txt");
story++;
std::cout << story << std::endl;
story--;
std::cout << story << std::endl;
}
//works
{
// test operator=
Word word("what");
word = hello;
std::cout << word << std::endl;
Sentence s(bye + cs240);
s = (hello + cs240);
std::cout << s << std::endl;
Paragraph p("It was a rainy day. Everyone stayed inside.");
p = s + (cs240 + Word("rocks"));
std::cout << p << std::endl;
Story story("input.txt");
story = story + p;
std::cout << story << std::endl;
}
//works upto here
{
// test operator+(int)
Word word("testing");
std::cout << word + 1231 << std::endl;
std::cout << word + 1 << std::endl;
Sentence s(hello + cs240);
s--;
std::cout << s + 1231 << std::endl;
std::cout << s + 1 << std::endl;
Paragraph p("it was a rainy day. everyone stayed inside.");
std::cout << p + 1231 << std::endl;
std::cout << p + 1 << std::endl;
Story story("input.txt");
story--;
std::cout << story + 1231 << std::endl;
std::cout << story + 1 << std::endl;
}
//works up to here now
{
// test prefix ++/--
Word w1("Like");
std::cout << w1 << "->";
std::cout << ++w1 << std::endl;
Word w2("likE");
std::cout << w2 << "->";
std::cout << ++w2 << std::endl;
Word w3("LikE");
std::cout << w3 << "->";
std::cout << ++w3 << std::endl;
Word w4("lIKe");
std::cout << w4 << "->";
std::cout << ++w4 << std::endl;
Word w5("this");
std::cout << w5 << "->";
std::cout << ++w5 << std::endl;
Word w6("TRASH");
std::cout << w6 << "->";
std::cout << ++w6 << std::endl;
Word w7("omelet");
std::cout << w7 << "->";
std::cout << ++w7 << std::endl;
Word w8("APPLE");
std::cout << w8 << "->";
std::cout << ++w8 << std::endl;
Sentence s1("In autumn apples are incredibly awesome.");
std::cout << ++s1 << "->";
std::cout << --s1 << std::endl;
Sentence s2("Like this.");
std::cout << ++s2 << "->";
std::cout << --s2 << std::endl;
std::cout << ++(s1+s2) << std::endl;
Story story("input.txt");
std::cout << std::endl << std::endl << ++story + (s1+s2) << std::endl;
std::cout << std::endl << std::endl << --(story + (s1+s2)) << std::endl;
}
//works upto here
{
// test first/rest
Sentence s1("In autumn apples are incredibly awesome.");
std::cout << s1.first() << std::endl;
std::cout << s1.rest() << std::endl;
Paragraph p1((hello+cs240) + s1);
std::cout << p1.first() << std::endl;
std::cout << p1.rest() << std::endl;
Story story("input.txt");
std::cout << story.first() << std::endl;
std::cout << p1 + story.rest() << std::endl;
}
//works upto here
{
// test story.save
Story story("input.txt");
++story;
story--;
Word good("good");
Word morning("morning");
Word night("night");
Paragraph intro((good + morning) + (hello + cs240));
Paragraph outro((good + night) + (bye + cs240));
intro++;
outro = outro + 1;
story = intro + story + outro;
story.save("output.txt");
}
//works
*/
return 0;
}