Question: Java: Create a class called WordList.java that has a private ArrayList attribute that holds Strings. Write a sort() method in this class that sorts the

Java:

Create a class called WordList.java that has a private ArrayList attribute that holds Strings.

Write a sort() method in this class that sorts the ArrayList using an algorithm of your choice.

Write a find( String word ) method that searches the ArrayList using a binary search. This method should return an int for the index of the word in the ArrayList. If the word is not found, the method should return -1.

Write a method: public String get( int position ) that returns the word found at the specified position.

Write a method: public int size() that returns the size of the ArrayList (using the size()method of the ArrayList.

Write a constructor that reads in the accompanying text file into the ArrayList and sorts it.

Write a brief driver class called WordTester.java with a single method (public static void main( String[] args )).

Declare and instantiate the WordList class (the list will be read and sorted in the constructor of the WordList.

Prompt the user for a word to search in the WordList.

Report whether or not the word was or was not found in the WordList.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!