-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutput.cpp
More file actions
59 lines (49 loc) · 1.26 KB
/
output.cpp
File metadata and controls
59 lines (49 loc) · 1.26 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
#include "output.h"
Output::Output() {}
Output::~Output() {}
void Output::setMode(const string mode) {
stdout = false;
logfile = false;
if(mode == "print") {
stdout = true;
}
else if(mode == "file") {
logfile = true;
}
}
void const Output::writeBlank(fstream &f) {
if(stdout) {
cout << endl;
}
if(logfile) {
f << endl;
}
}
void const Output::writeCommand(const string cycle, const int words, const int num, const string direction, fstream &f) {
if(stdout) {
cout << "Line " << num << ": ";
cout << cycle << " " << direction << " command: ";
cout << words << " words" << endl;
}
if(logfile) {
f << "Line " << num << ": ";
f << cycle << " " << direction << " command: ";
f << words << " words" << endl;
}
}
void const Output::writeRate(const string rate, const string cycle, const string direction, fstream &f) {
if(stdout) {
cout << cycle << " " << direction << ": " << rate << endl;
}
if(logfile) {
f << cycle << " " << direction << ": " << rate << endl;
}
}
void const Output::writeWords(const string data, const int wordPos, const int num, fstream &f) {
if(stdout) {
cout << "Line " << num << ": Word " << wordPos << ": " << data << endl;
}
if(logfile) {
f << "Line " << num << ": Word " << wordPos << ": " << data << endl;
}
}