forked from alexbaotranho11/CPSC131Project2
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTexttool.h
More file actions
98 lines (69 loc) · 1.44 KB
/
Texttool.h
File metadata and controls
98 lines (69 loc) · 1.44 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
#pragma once
#pragma once
#include <string>
#include <stdexcept>
#include <fstream>
#include <iostream>
#include <list>
using namespace std;
class TextTool {
public:
// default constructor
TextTool() {
// TO BE COMPLETED
}
// destructor
~TextTool() {
// TO BE COMPLETED
}
// Load information from a text file with the given filename.
void loadListFromTextfile(string filename) {
ifstream ifs;
ifs.open(filename);
if (ifs.is_open()) {
string aword;
while (ifs >> aword) {
addEntryBack(aword);
}
ifs.close();
}
else
throw invalid_argument("Could not open file " + filename);
}
// return the number of words in the linked list
int totalWords() {
return -1; // TO BE COMPLETED
}
// add entry at the back of the linked list
void addEntryBack(const string& aword) {
// TO BE COMPLETED
}
// print all words stored in the linked list, separated by a space
const string listToString() {
// TO BE COMPLETED
}
// print duplicated words in the linked list
void printDuplicates() {
// TO BE COMPLETED
}
// remove duplicated words in the linked
void removeDuplicates() {
// TO BE COMPLETED
}
// determine the total number of duplicated words in the list
int totalDuplicates() {
// TO BE COMPLETED
}
// check if the list is empty
bool isEmpty() {
//TBC
}
// Empty the list
void makeEmpty() {
// TO BE COMPLETED
}
private:
int n;
int duplicates;
list<string> *wordlist;
};