-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnagramClass.java
45 lines (43 loc) · 1.02 KB
/
AnagramClass.java
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
package anagrams;
public class AnagramClass {
private int hashIndex;
private int uniqueID;
private String word;
private LinkedList anagrams;
public AnagramClass(int index, int id, String word){
this.hashIndex = index;
this.uniqueID = id;
this.word = word;
LLNode newNode = new LLNode(null, word);
this.anagrams = new LinkedList(newNode);
}
//Accessors
public int getHashIndex(){
return hashIndex;
}
public int getUniqueID(){
return uniqueID;
}
public LinkedList getAnagrams(){
return anagrams;
}
public String getWord(){
return word;
}
public void addAnagram(String word){
LLNode newNode = new LLNode(null,word);
this.anagrams.addToList(newNode);
}
public String ClassToString(){
String returnString ="";
LLNode curr = new LLNode(null,null);
//if(anagrams.getLength() > 5){ //if you want classes with 5 or more members
curr = anagrams.getFirst();
while(curr.getNext() != null){
returnString += (curr.getWord() + " ");
curr = curr.getNext();
}
//}
return returnString;
}
}