Lab 2: Dictionary File Reading Program

Due Date and Submission Requirements


The goal of this lab is:


Background and Directions

In this assignment, you will be forming a dictionary in your program from reading from a file. You will use words.txt. To fill your dictionary. This file has most of the words in the english dictionary.

Using Lab2Demo.Java, as a starting point, you will supply the necessary classes and methods to get the correct output. You can download this file, or copy and paste it into your own Lab2Demo.java.

You first need to define the instance fields and constructor for the Dictionary class. There will be at least one instance field. You will need to keep track of all the words from the input file, which will be a String[]. You will only read from the file once. I would recommend writing a method, perhaps called readFromFile() which will open the file, and then return the filled array of Strings.

public Dictionary() {

   this.words = readFromFile();

}

There are 41193 words in the input file. You can hardcode this value in your code when creating the array. The words are not in alphabetical order. You will need to make sure the words are sorted alphabetically in your dictionary before moving to the next part.

In the Dictionary class, you will need to define the following methods:

Rules

You are NOT allowed to modify Lab2Demo.java. If you modify Lab2Demo.Java in any way, then you will lose significant points! The TAs will grade with the same demo class, and same input file.

Starting Code

Required Output

When your program is run, your output should look exactly the same as seen in this screenshot .

Grading (10 points)