Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Cannot find symbol in Java Boggle class Create member variables of type: ArrayList of class String // stores data from data file with dice data

Cannot find symbol in Java

Boggle class

Create member variables of type:

ArrayList of class String // stores data from data file with dice data

String // set to the name of input file BoggleData.txt

ArrayList of class String // stores data from data file with dictionary data

String // set to the name of input file Dictionary.txt

Method main() should:

Instantiate an instance of class ReadDataFile passing the file name variable for file BoggleData.txt as an argument

Call method populateData on the above object

Instantiate an instance of class ReadDataFile passing the file name variable for file Dictionary.txt as an argument

Call method populateData on the above object

Instantiate an instance of class Board passing as arguments method call getData on each of the two ReadDataFile object references from above

Call method populateDice on object reference of class Board

Output to the IDE output window the number of objects in the ArrayList of type String that stores the dictionary data

IReadDataFile interface

Create interface IReadDataFile

Add method signature:

populateData with no return type and an empty parameter list

ReadDataFile class

Update the class so that it implements interface IReadDataFile

TIP: Use Netbeans right click menu, Insert Code, Implement Method to have the IDE generate the methods for you; you will replace the throw exception statements with the source code you write

Add member variables using the specified data types:

Scanner // for reading the file

String // for storing the file name

ArrayList of class String // for storing the data from the file

TIP: member variables should have an access level modifier of private to protect the data

Add a custom constructor that receives one parameter of type String representing the name of the data file to read; it should do the following:

Set the member variable of type String for storing the file name equal to the parameter

Instantiate the member variable of type ArrayList

Add a getter for the ArrayList member variable that stores the data read from the data file

TIP: Use the IDE right click menu, Refactor, Encapsulate Fields and select just getter for the member variable of focus

Implement method populateData; it should do the following:Instantiate an instance of Java API class URL passing as an argument member variable representing the file name of the data file

TIP: this is a unique implementation, to instantiate the instance set the URL variable equal to static method call getClass().getResource()

Instantiate an instance of class File using the URL created above

Initialize member variable of type Scanner based on the File instance created above

TIP: pass as an argument to the constructor the reference object of the URL instance with method call .toURI()

Loop through the data file until the end

Add to the ArrayList representing the data in the file each value read from the data file

import java.io.*; import java.util.ArrayList;

public class Boggle {

private static ArrayList boggleData = new ArrayList(); private static final String dataFileName = "BoggleData.txt"; private static ArrayList dictionaryData = new ArrayList(); private static final String dictionaryFileName = "Dictionary.txt"; public static void main(String[] args) { ReadDataFile data = new ReadDataFile(dataFileName); data.populateData(); ReadDataFile dictionary = new ReadDataFile(dictionaryFileName); dictionary.populateData(); Board newBoard = new Board(data.getData(), dictionary.getData()); newBoard.populateDice(); int itemCount = dictionaryData.size(); System.out.println("There are " + itemCount + " entries in the dictionary"); } }

public class ReadDataFile implements IReadDataFile {

private Scanner inputFile; private String dataFileName; private ArrayList data;

public ReadDataFile(String fileName) { dataFileName = fileName; data = new ArrayList(); } public ArrayList getData() { int i = 0; for(i=0; i

public static void main(String args[]){ ReadDataFile r = new ReadDataFile("BoggleData.txt"); r.populateData; r.getData }

public interface IReadDataFile { public void populateData(); }

I'm getting a "cannot find symbol" under ReadDataFile in the Board class.

Im not quite sure why it's not coming together

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

1. Explain the 2nd world war. 2. Who is the father of history?

Answered: 1 week ago

Question

How do we organise for international logistics?

Answered: 1 week ago

Question

What are the logistics implications of internationalisation?

Answered: 1 week ago