aboutsummaryrefslogtreecommitdiffstats
path: root/csci1913/Java/project3
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2019-12-10 10:05:27 -0600
committerRossTheRoss <msattr@gmail.com>2019-12-10 10:05:27 -0600
commit66260b0a740562c1a8ae8a576f71a50def5f9ce1 (patch)
treefe0f4f0d2e96dfc77b625e6a6b02d298349e5e28 /csci1913/Java/project3
parentIt's a little fucked mate (diff)
downloadhomework-66260b0a740562c1a8ae8a576f71a50def5f9ce1.tar
homework-66260b0a740562c1a8ae8a576f71a50def5f9ce1.tar.gz
homework-66260b0a740562c1a8ae8a576f71a50def5f9ce1.tar.bz2
homework-66260b0a740562c1a8ae8a576f71a50def5f9ce1.tar.lz
homework-66260b0a740562c1a8ae8a576f71a50def5f9ce1.tar.xz
homework-66260b0a740562c1a8ae8a576f71a50def5f9ce1.tar.zst
homework-66260b0a740562c1a8ae8a576f71a50def5f9ce1.zip
Finish lab?????
Diffstat (limited to '')
-rw-r--r--csci1913/Java/project3/project3_strap012.java23
-rw-r--r--csci1913/Java/project3/the.txt5
2 files changed, 21 insertions, 7 deletions
diff --git a/csci1913/Java/project3/project3_strap012.java b/csci1913/Java/project3/project3_strap012.java
index 966c4fb..4c1f0a6 100644
--- a/csci1913/Java/project3/project3_strap012.java
+++ b/csci1913/Java/project3/project3_strap012.java
@@ -41,7 +41,15 @@ class AnagramTree {
goLeft = false;
bottom = bottom.right;
} else {
- bottom.words = new WordNode(word, bottom.words);
+ WordNode badNode = bottom.words;
+ boolean wordExists = false;
+ while (badNode != null) {
+ if (badNode.word.equals(word))
+ wordExists = true;
+ badNode = badNode.next;
+ }
+ if (!wordExists)
+ bottom.words = new WordNode(word, bottom.words);
addWord = true;
break;
}
@@ -59,16 +67,16 @@ class AnagramTree {
}
public void anagrams() {
- System.out.println(findAnagrams(head.right)); //e should be lower than other words as it is e
+ findAnagrams(head.right); //e should be lower than other words as it is e
}
- private String findAnagrams(TreeNode subtree) {
- StringBuilder builder = new StringBuilder();
+ private void findAnagrams(TreeNode subtree) {
try {
if (subtree.words.next != null) {
+ System.out.println();
while (subtree.words != null) {
- builder.append(subtree.words.word);
- builder.append(" ");
+ System.out.print(subtree.words.word);
+ System.out.print(" ");
subtree.words = subtree.words.next;
}
}
@@ -79,7 +87,8 @@ class AnagramTree {
} catch (NullPointerException ignore) {
//Do nothing
}
- return builder.toString();
+
+
}
private int compareSummaries(byte[] left, byte[] right) {
diff --git a/csci1913/Java/project3/the.txt b/csci1913/Java/project3/the.txt
new file mode 100644
index 0000000..6afe356
--- /dev/null
+++ b/csci1913/Java/project3/the.txt
@@ -0,0 +1,5 @@
+the the the the eht the the the
+the
+the het
+hte
+the \ No newline at end of file