Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

package code; import java.io.IOException; import java.nio.file.Files; import jav

ID: 3598542 • Letter: P

Question

package code;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

public class Model {

// Determines the maximum length of a word
private static final int MAXIMUM_WORD_LENGTH = 7;

// Determines the maximum length of a word
private static final int MINIMUM_WORD_LENGTH = 3;

// Holds all words from the dictionary file that have lengths between the max and min, inclusive
private ArrayList<String> _words;

// Holds all words from the dictionary file that have the max length
private ArrayList<String> _seedWords;

// Holds all words from _words that must be found by the player
private HashMap<String,Boolean> _wordsToFind;


/* QUESTION 1
*
* The constructor
*
* The job of the constructor is to assign sensible initial values to each instance variable.
   * To _words it should assign the value returned by readDictionaryFromFile, with the filename passed in as argument
   * To _seedWords it should assign the value returned by filterWordsForLength, with _words and the maximum word length passed in as arguments
   * To _wordsToFind it should assign the value null.

*
* @param filename - the name of a file of words (a "dictionary file")
*/
public Model(String filename) {
  
  
  // TODO Auto-generated method stub
}

Explanation / Answer

I belived that this task only for constructor that assign thhe value to instance variables by calling required methods

so i have two required methods(not completed) as needed

package code;

import java.io.IOException;

import java.nio.file.Files;

import java.nio.file.Paths;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.HashSet;

public class Model {

// Determines the maximum length of a word

private static final int MAXIMUM_WORD_LENGTH = 7;

// Determines the maximum length of a word

private static final int MINIMUM_WORD_LENGTH = 3;

// Holds all words from the dictionary file that have lengths between the max and min, inclusive

private ArrayList<String> _words;

// Holds all words from the dictionary file that have the max length

private ArrayList<String> _seedWords;

// Holds all words from _words that must be found by the player

private HashMap<String,Boolean> _wordsToFind;

/* QUESTION 1

*

* The constructor

*

* The job of the constructor is to assign sensible initial values to each instance variable.

* To _words it should assign the value returned by readDictionaryFromFile, with the filename passed in as argument

* To _seedWords it should assign the value returned by filterWordsForLength, with _words and the maximum word length passed in as arguments

* To _wordsToFind it should assign the value null.

*

* @param filename - the name of a file of words (a "dictionary file")

*/

public Model(String filename) {

this._words=readDictionaryFromFile(filename);//assigned to sensible var

this._seedWords=filterWordsForLength(_words,MAXIMUM_WORD_LENGTH);//assigned to sensible var

this._wordsToFind=null;//assigned to null as given

}

//added the methods as per requirement

private ArrayList<String> filterWordsForLength(ArrayList<String> _words2, int maximumWordLength) {

//UNIMPLEMENTED

//this method will used to filter words

return new ArrayList<>();

}

private ArrayList<String> readDictionaryFromFile(String filename) {

// UNIMPLEMENTED

//this method will read words from file

return new ArrayList<>();

}

}

//Please do let me know if u have any concern....