Penn foster Graded Project 4 BoardGameTester application Java

Availability: In stock

Regular Price: $20.00

Special Price: $15.00

OR

Penn foster Graded Project 4 BoardGameTester application Java

Double click on above image to view full picture

Zoom Out
Zoom In

More Views

Quick Overview

Penn foster Graded Project 4 BoardGameTester application Java

In this project, you'll modify the BoardGameTester application to save the gameboard to a file. You'll perform the file writing process on a separate thread.

INSTRUCTIONS
1. In NetBeans, open the BoardGameTester project.
2. Create a new package named games.utilities.
3. Add a public class named FileManager that contains the following methods:
public static void writeToFile(String saveState, String fileName) {
//TODO: Write a string to a new file synchronously
}
public static void writeToFileAsync(final String saveState, final String fileName) {
//TODO: Write a string to a new file asynchronously
}
4. Implement the writeToFile method using the new file I/O classes in a try-with-resources statement.
Note: Use the code in Activity 15 as a guide for the writeToFile method. Remember to import the java.io, java.nio, java.nio.charset, and java.nio.file packages.
5. Implement the writeToFileAsync method using a separate thread. Use the following code as a guide:
new Thread() {
public void run() {
writeToFile(saveState, fileName);
}
}.start();
Note: This code uses an anonymous inner class to declare and instantiate a Thread class. Unlike a traditional inner class, anonymous inner classes are available only within the statement they're declared. You'll see more examples of anonymous classes with Swing in the next lesson. To ensure that local variables are unchanged by the inner class, the parameters saveState and fileName must be declared with the final keyword.
6. In the main() method of the BoardGameTester project, add the following code:
FileManager.writeToFileAsync(ticTacToe.toString(), "ttt.txt");
FileManager.writeToFileAsync(connectFour.toString(), "c4.txt");
FileManager.writeToFileAsync(mastermind.toString(), "mm.txt");
7. Compile and run the project to create three files, one for each saved board game. Open the files to ensure they contain the correct game board display.
Note: Notepad won’t display the line returns in the file. You may need to open the text files using Microsoft Word or Wordpad instead.
These three game board files will be required for submission.

Regular Price: $20.00

Special Price: $15.00

Details

Penn foster Graded Project 4 BoardGameTester application Java

In this project, you'll modify the BoardGameTester application to save the gameboard to a file. You'll perform the file writing process on a separate thread.

INSTRUCTIONS
1. In NetBeans, open the BoardGameTester project.
2. Create a new package named games.utilities.
3. Add a public class named FileManager that contains the following methods:
public static void writeToFile(String saveState, String fileName) {
//TODO: Write a string to a new file synchronously
}
public static void writeToFileAsync(final String saveState, final String fileName) {
//TODO: Write a string to a new file asynchronously
}
4. Implement the writeToFile method using the new file I/O classes in a try-with-resources statement.
Note: Use the code in Activity 15 as a guide for the writeToFile method. Remember to import the java.io, java.nio, java.nio.charset, and java.nio.file packages.
5. Implement the writeToFileAsync method using a separate thread. Use the following code as a guide:
new Thread() {
public void run() {
writeToFile(saveState, fileName);
}
}.start();
Note: This code uses an anonymous inner class to declare and instantiate a Thread class. Unlike a traditional inner class, anonymous inner classes are available only within the statement they're declared. You'll see more examples of anonymous classes with Swing in the next lesson. To ensure that local variables are unchanged by the inner class, the parameters saveState and fileName must be declared with the final keyword.
6. In the main() method of the BoardGameTester project, add the following code:
FileManager.writeToFileAsync(ticTacToe.toString(), "ttt.txt");
FileManager.writeToFileAsync(connectFour.toString(), "c4.txt");
FileManager.writeToFileAsync(mastermind.toString(), "mm.txt");
7. Compile and run the project to create three files, one for each saved board game. Open the files to ensure they contain the correct game board display.
Note: Notepad won’t display the line returns in the file. You may need to open the text files using Microsoft Word or Wordpad instead.
These three game board files will be required for submission.

Product Tags

Use spaces to separate tags. Use single quotes (') for phrases.