Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java boggle program Boggledata.txt includes: D R L X E I C P O H S A N H N L Z R W T

Java boggle program

Boggledata.txt includes:

D R L X E I C P O H S A N H N L Z R W T O O T A I O S S E T N W E G H E B O O J A B U I E N E S P S A F K F I U N H M Qu Y R D V E L V E H W H R I O T M U C T Y E L T R S T I T Y D A G A E E N

dictionary.txt just includes a 61,406 words

The output should look like

Die 0: D R L X E I

looped all the way up to

Die 15: A G A E E N

as well as saying: "There are (number of dictionary.txt entries) entries in the dictionary"

Activity

Boggle project

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

core package

IBoard interface

Add constant fields:

NUMBER_OF_DICE equal to value 16

GRID equal to value 4

Add method signatures:

populateDice with return type void and an empty parameter list

shakeDice with return type ArrayList and an empty parameter list

Board class

Update the class so that it implements interface IBoard

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 variable of type:

ArrayList of class String // stores dice data

ArrayList of class String // stores dictionary data

ArrayList of class Die // stores 16 game dice

Add a custom constructor with two parameters of type ArrayList of class String; it should do the following

Set the member variable of type ArrayList of class String that stores the Boggle data equal to the associated parameter in the method signature

Set the member variable of type ArrayList of class String that stores the dictionary data equal to the associated parameter in the method signature

Instantiate the member variable of type ArrayList of class Die.

Implement method populateDice; the method should do the following:

Declare a variable of type class Die

Declare and initialize a variable of type int to serve as a counter to access the data in the member variable of type ArrayList of type String storing the Boggle data

Loop through the 16 dice (use the constant NUMBER_OF_DICE as your terminating condition):

Instantiate the instance of class Die using the default no-argument constructor

For each Die instance, loop through the six sides of the die (use the constant NUMBER_OF_SIDES as your terminating condition):

Add each of the 6 letters to the Die ArrayList representing the die letters by calling method addLetter in class Die

Display the letters of each die by calling method displayLetters() in class Die on a separate row

Add each die instance to the ArrayList declared specifically for class Die

IDie interface

Add constant field:

NUMBER_OF_SIDES equal to value 6

Add method signatures:

rollDie with return type String and an empty parameter list

addLetter with a return type of void and one parameter of type String representing one of the six letters on the die

displayLetters with a return type of void and an empty parameter list

Die class

Update the class so that it implements interface IDie

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 variable of type:

ArrayList // stores dice data for the sides of the die

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

Implement method addLetter; the method should:

Add the parameter to the ArrayList representing the letters on the die

Implement method displayAllLetters; the method should:

Use an enhanced for loop to output the letter on each of the six sides of the die

inputOutput package

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

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_2

Step: 3

blur-text-image_3

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

Database And Expert Systems Applications 22nd International Conference Dexa 2011 Toulouse France August/September 2011 Proceedings Part 1 Lncs 6860

Authors: Abdelkader Hameurlain ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2011th Edition

3642230873, 978-3642230875

More Books

Students also viewed these Databases questions

Question

3. Evaluate your listeners and tailor your speech to them

Answered: 1 week ago