Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: HangmanLexicon.java
- * -------------------------
- * This file contains a stub implementation of the HangmanLexicon
- * class that you will reimplement for Part III of the assignment.
- */
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import acmx.export.java.util.ArrayList;
- public class HangmanLexicon {
- public ArrayList list;
- public HangmanLexicon() {
- try {
- BufferedReader rd = new BufferedReader(new FileReader("HangmanLexicon.txt"));
- while (true) {
- String str = rd.readLine();
- if (str == null)
- break;
- list.add(str);
- }
- rd.close();
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- /** Returns the number of words in the lexicon. */
- public int getWordCount() {
- return list.size();
- }
- /** Returns the word at the specified index. */
- public String getWord(int index) {
- return (String) list.get(index);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement