-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWordData.java
More file actions
108 lines (92 loc) · 2.27 KB
/
WordData.java
File metadata and controls
108 lines (92 loc) · 2.27 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
/**
* @author Rakith "Jay" Jayewardene
* raj69
* Establishes a class named "WordData" that collects data from a file of words.
*/
import java.util.LinkedList;
import java.util.Scanner;
public class WordData {
// stores an index
private int index;
// stores a string
private String string;
// stores a boolean
private boolean bool;
// stores a LinkedList
private LinkedList<Integer> list;
/**
* This method retrieves the index
* @return index
*/
public int getIndex() {
return index;
}
/**
* This method sets the index of a WordData object in list
* @param index
*/
public void setIndex(int index) {
this.index = index;
}
/**
* This methid retrieves the String
* @return string
*/
public String getString() {
return string;
}
/**
* This method sets the String
* @param string
*/
public void setString(String string) {
this.string = string;
}
/**
* This method retrieves the boolean
* @return bool of type Boolean
*/
public boolean getBool() {
return bool;
}
/**
* This method sets the boolean
* @param a single boolean
*/
public void setBool(boolean bool) {
this.bool = bool;
}
/**
* This method retrieves the list
* @return list
*/
public LinkedList<Integer> getList() {
return list;
}
/**
* This method sets the list
* @param LinkedList<Integer>
*/
public void setList(LinkedList<Integer> list) {
this.list = list;
}
/**
* A method that parses through a WordIndex file and sets the string, boolean, and list
* @param stringInput of the WordIndex file form
* @return a WordData object named "return"
*/
public static WordData parseWordData(String wordIndexFile) {
LinkedList<Integer> list = new LinkedList<Integer>();
Scanner scanner = new Scanner(wordIndexFile);
scanner.next();
while (scanner.hasNextInt()) {
Integer thisIndex = new Integer(scanner.nextInt());
list.add(thisIndex);
}
WordData result = new WordData();
result.setString(wordIndexFile);
result.setBool(false);
result.setList(list);
return result;
}
}