Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
2onefan2 committed Apr 29, 2024
1 parent 44b4806 commit 071754a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 160 deletions.
114 changes: 0 additions & 114 deletions src/test/java/uta/cse3310/GridField.java

This file was deleted.

58 changes: 58 additions & 0 deletions src/test/java/uta/cse3310/WordList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package uta.cse3310;

import java.io.IOException;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class WordList {
public static List<String> list;

public static ArrayList<String> getWordList(String wordsFile) {
ArrayList<String> wordList = new ArrayList<>();

try {
List<String> lines = Files.readAllLines(Paths.get(wordsFile));
if (lines.isEmpty()) {
System.out.println("The file is empty: " + wordsFile);
return wordList; // Return empty list if the file is empty
}

list = new ArrayList<>(lines);
shuffleWords();
wordList.addAll(list);
} catch (IOException e) {
System.out.println("Error reading the file: " + wordsFile);
e.printStackTrace(); // Print the stack trace for debugging
}

return wordList;
}

public static void shuffleWords() {
Collections.shuffle(list);
}

public static ArrayList<String> updatedWordList(ArrayList<String> wordBank) {
int totalCharacters = 0;
int index = 0;
ArrayList<String> updatedList = new ArrayList<>();

while (totalCharacters < 500 && index < wordBank.size()) {
String word = wordBank.get(index);
if (totalCharacters + word.length() <= 500) {
updatedList.add(word);
totalCharacters += word.length();
} else {
break;
}
index++;
}

return updatedList;
}
}
46 changes: 0 additions & 46 deletions src/test/java/uta/cse3310/WordListTest.java

This file was deleted.

0 comments on commit 071754a

Please sign in to comment.