Advertisement
TBark19

Untitled

Dec 8th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. /*
  2. * File: HangmanLexicon.java
  3. * -------------------------
  4. * This file contains a stub implementation of the HangmanLexicon
  5. * class that you will reimplement for Part III of the assignment.
  6. */
  7.  
  8. import java.io.BufferedReader;
  9. import java.io.FileNotFoundException;
  10. import java.io.FileReader;
  11. import acmx.export.java.util.ArrayList;
  12.  
  13. public class HangmanLexicon {
  14.  
  15. public ArrayList list;
  16.  
  17. public HangmanLexicon() {
  18. try {
  19. BufferedReader rd = new BufferedReader(new FileReader("HangmanLexicon.txt"));
  20. while (true) {
  21. String str = rd.readLine();
  22. if (str == null)
  23. break;
  24. list.add(str);
  25. }
  26. rd.close();
  27. } catch (FileNotFoundException e) {
  28. // TODO Auto-generated catch block
  29. e.printStackTrace();
  30. }
  31. }
  32.  
  33. /** Returns the number of words in the lexicon. */
  34. public int getWordCount() {
  35. return list.size();
  36. }
  37.  
  38. /** Returns the word at the specified index. */
  39. public String getWord(int index) {
  40. return (String) list.get(index);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement