Question
BoggleData.txt: D R L X E I C P O H S A N H N L Z R W T O O T A
BoggleData.txt:
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 contains a dictionary of words from the boggle dictionary.
Assignment Scope
Adding member variables or instance variable in a class
Generating getters/setters for member variables
Instantiating an instance of a class
Calling a method of a class using the reference object
Using Java API class ArrayList
Reading a data fileUsing a try/catch/finally block to handle exceptions and close resource files
IOException
URISyntaxException
Using Java API class Scanner
Using Java API class URL
Using Java API class File
Saving data from a data file in an ArrayList
Adding method signatures to an interface
Adding a constant to an interface
Implementing an interface
Using the enhanced for loop
Deliverables
To complete this assignment you must submit your compressed Netbeans project to Webcourses.
Tasks and Rubric
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 followingSet 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 fileTIP: 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 fileTIP: 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 aboveTIP: 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 endAdd to the ArrayList representing the data in the file each value read from the data file |
userInterface package |
|
Boggle application |
|
Test Case 1 | Test Case 1 passes |
Test Case 2 | Test Case 2 passes |
Test Case 3 | Test Case 3 passes |
| Source compiles with no errors |
| Source runs with no errors |
| Source includes comments |
Total |
|
Perform the following test cases
Test Cases | ||
| Action | Expected outcome |
Test Case 1 | Project view | Completed project view should look like figure 1 |
Test case 2 | Run application | displayLetters should look like figure 2 |
Test case 3 | Run application | Size of ArrayList storing dictionary data should be similar to figure 3 |
Figure 1 Output from method displayLetters
Die 1: D R L X E I Die 2: C P O H S A Die 3: N H N L Z R Die 4: W T O O T A Die 5: I O S S E T Die 6: N W E G H E Die 7: B O O J A B Die 8: U I E N E S Die 9: P S A F K F Die 10: I U N H M Qu Die 11: Y R D V E L Die 12: V E H W H R Die 13: I O T M U C Die 14: T Y E L T R Die 15: S T I T Y D Die 6: A G A E E N
Figure 2 Output for number of entries in the Dictionary.txt file
There are 62406 entries in the dictionary.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started