Question: Code from the above image import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class QueryResults { // class variables go here /**

 Code from the above image import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList;

import java.util.List; import java.util.Scanner; public class QueryResults { // class variables go

here /** * Constructor for the QueryResults class. * Initialize the dictionary

and list objects * @param filename name of the dictionary file *@throws FileNotFoundException exception is thrown to the calling method if unable to

Code from the above image

import java.io.File;

import java.io.FileNotFoundException;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class QueryResults {

// class variables go here

/**

* Constructor for the QueryResults class.

* Initialize the dictionary and list objects

* @param filename name of the dictionary file

* @throws FileNotFoundException exception is thrown to the calling method if unable to open file

*/

public QueryResults(String filename) throws FileNotFoundException {

// Call the readDictionary method to assign contents to the member variable, dictionary.

// Instantiate a new ArrayList for the list variable.

}

/**

* Getter method for the dictionary object.

* @return {@link java.util.List} dictionary object

*/

public List getDictionary() {

return null;

}

/**

* Getter method for the list object.

* @return {@link java.util.List} of words found in {@link QueryResults#searchDictionary} method.

*/

public List getList() {

return null;

}

/**

* Get number of recursive calls.

* @return the number of recursive calls used in {@code searchDictionary}.

*/

public int getCount() {

return 0;

}

/**

* Getter method for the current string being queried.

* @return the word being queried

*/

public String getWord(){

return null;

}

/**

* Create a new {@link java.util.List} and then read each token from

* the file called {@code filename} and add it into the

* {@link java.util.List}.

*

* @param filename name of file

* @return A list of legal words to use for this recitation

* @throws FileNotFoundException exception is thrown to the calling method if unable to open file.

* @see Scanner#hasNext()

* @see Scanner#next()

*/

public List readDictionary(String filename) throws FileNotFoundException{

return null;

}

/**

* Recursively search substrings of the parameter {@code word}

* and store uniquely in the {@link java.util.List} {@code list}.

*

*

*

    *

  1. Assign {@code word} into the corresponding member variable

    *

  2. Set the member variable for count back to 0

    *

  3. Assign {@code list} to the return value for {@link QueryResults#searchDictionaryHelper(List, String)} method.

    * Pass in a new ArrayList and the word as parameters.

    *

*

* @param word the word to query.

*/

public void searchDictionary(String word) {

}

/**

* Helper method for {@code searchDictionary}.

*

* Your recursive logic goes here:

*

*

    *

  1. If the word is less than or equal to two characters, return {@code wordList}.

    *

  2. Increment the counter.

    *

  3. Add the word if it is in the dictionary but not already in the list.

    *

  4. Recursively call the method twice: Once with the first character removed

    * and once with the last character removed.

    *

* Use {@link ArrayList#contains(Object)}.

* @param wordList A List of unique legal substrings from the parameter, word

* @param word The word being queried

* @return A List of unique legal substrings from the parameter, word

* @see ArrayList#contains(Object)

*/

public List searchDictionaryHelper(List wordList, String word){

return wordList;

}

/**

* toString for you QueryResults class.

* @return String that prints information about the class

*/

@Override

public String toString() {

// Remember to double check your formatting

return "";

}

public static void main(String [] args) throws FileNotFoundException {

// Instantiate object

QueryResults qr = new QueryResults(args[0]);

// Call searchDictionary method with a word

qr.searchDictionary(args[1].toLowerCase());

// Print list of words found

// you could also type: System.out.println(qr.toString());

System.out.println(qr);

}

}

Example of the dictonary words used, but just a regular dictonary

a

aardvark

aardwolf

ab

aba

abaca

abacist

aback

abactinal

abacus

abaddon

abaft

abalienate

abalienation

abalone

abampere

abandon

abandoned

abandonment

abarticulation

abase

abased

abasement

abash

abashed

abashment

abasia

abasic

abate

abatement

abating

abatis

abatjour

abattis

abattoir

abaxial

abba

5 import 7 public class QueryResults 8 class variables go here 100 / Constructor for the QueryResults class. Initialize the dictionary and list objects eparam filename name of the dictionary file 12 14 ethrows FileNotFoundException exception is thrown to the calling method if unable to open file 16 public QueryResults (String filename) throws FileNotFoundException t 7Call the readDictionary method to assign contents to the member variable, dictionary /Instantiate a new ArrayList for the list variable 20 21 e sp 23 24 25 26 Getter method for the dictionary object. ereturn [elink java.util.List dictionary object public List getDictionaryO return nul 28 29 30 e s Getter method for the list object * @return {@link java .util List} of words found in {@link QueryResults#searchDictionary} method. 32 public List getListO 34 35 36 return nul e sp Get number of recursive calls 39 40 ereturn the number of recursive calls used in tecode searchDictionary. 41 public int getCount return 0

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!