Study Guide Template NOTES Advanced Programming Logic OVERVIEW Now you’re ready to add file I/O to your board game applica- tion. This project will assess your understanding of writing a file and...

2 answer below »
my next assignment needed number 4 out of 6


Study Guide Template NOTES Advanced Programming Logic OVERVIEW Now you’re ready to add file I/O to your board game applica- tion. This project will assess your understanding of writing a file and using multithreading. Make sure to follow all directions completely and verify your results before submitting the project for grading. Remember to include all required components in your solution. YOUR PROJECT In this project, you’ll modify the BoardGameTester applica- tion 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: G ra d e d P ro je c t G ra d e d P ro je c t 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 sepa- rate 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 tradi- tional 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: Remember to import the games.utilities package! 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. FileManager.writeToFileAsync(ticTacToe.toString(), “ttt.txt” ); FileManager.writeToFileAsync(connectFour.toString( ), “c4.txt” ); FileManager.writeToFileAsync(mastermind.toString() , “mm.txt” ); SUBMISSION GUIDELINES To submit your project, you must provide the following source code files in a ZIP file: ■ BoardGameTester.java ■ FileManager.java ■ ttt.txt ■ c4.txt ■ mm.txt To find the Java source files within NetBeans, go to the BoardGameTester project folder. To determine this folder, right-click on BoardGameTester project in the Projects panel. Copy the value for the Project Folder textbox using the keyboard shortcut CTRL+C. In Windows Explorer, paste the project folder path and hit the ENTER key. Copy both the BoardGameTester.java file from the src\boardgametester folder and the FileManager.java file from the src\games\ utilities folder to your desktop or any other temporary loca- tion. The three game board files will be located at the root of the project folder. Follow this procedure to submit your project online: 1. Log on to the Penn Foster website and go to student por- tal. 2. Click Take Exam. 3. Attach your zip file as follows: a. Click on the Browse box. b. Locate the file you wish to attach. c. Double-click on the file. d. Click Upload File. 4. Enter your e-mail address in the box provided. (Note: This information is required for online submissions.) 5. If you wish to tell your instructor anything specific regarding this assignment, enter it in the Message box. 6. Click Submit File. GRADING CRITERIA Your instructor will use the following guidelines to grade your project. FileManager class correctly defined 40 points BoardGameTester class correctly modified 20 points All three game board files are correct 20 points All source code and files are included 20 points TOTAL 100 points Graphical User Interface Design INTRODUCTION So far you’ve focused on developing command-line applications that strictly control text-based input/output. Most modern applications use a graphical user interface (GUI) for input/ output and rely on user events to perform their operations. In this lesson, you’ll be introduced to the APIs for the abstract windowing toolkit (AWT), Swing, and JavaFX. After completing this lesson, you’ll be prepared to create robust and user- friendly applications in Java! OBJECTIVES When you complete this lesson, you’ll be able to ■ Discuss Java applet technology and life cycle ■ Create and use a Java applet ■ Use the Graphics class to paint text and basic shapes ■ Register and handle standard events ■ Differentiate Swing from the abstract windowing toolkit (AWT) ■ Explain the model-view-controller pattern ■ Use layout managers to organize Swing components ■ Create and add standard Swing components ■ Create an applet with Swing ■ Describe JavaFX technology L e s s o n 5 L e s s o n 5 ASSIGNMENT 15: CREATE APPLETS AND HANDLE EVENTS Read Assignment 15 in this study guide. Then read Chapter 15, pages 511–534, as well as Chapter 16, pages 573–575, in your textbook. Create Applets and Handle Events Assignment 14 introduces applets and event handling using the abstract windows toolkit, and covers anonymous inner classes and lambda expressions. Be sure to complete the Try This activities in Chapter 15. Applet Basics An applet is a small GUI application embedded in a Web page. Applets are often built as executable Java archive (JAR) files and are executed by the JVM associated with a brower’s plug-in manager. Because applets are automatically loaded by the browser, Java applets run in security sandbox to pro- tect the client OS from malicious code. Unsigned applets are those that aren’t signed with a valid certificate from a trusted certificate authority (CA). They can’t access the local file sys- tem or other remote Web servers. Signed applets can run in standalone mode and are limited only by general OS security. Applets are embedded in Web pages in the same way as other multimedia is. In earlier versions of HTML, you would use the element, while the element is preferred for HTML5. The following HTML embeds an applet in a Web page: Applet failed to run. Please install the Java plug-in. The type attribute specifies the Multipurpose Internet Mail Extensions (MIME), so that the browser knows to use the Java plug-in. The code parameter specifies the applet class,
Answered Same DayMar 11, 2021

Answer To: Study Guide Template NOTES Advanced Programming Logic OVERVIEW Now you’re ready to add file I/O to...

Aditi answered on Mar 21 2021
145 Votes
Solution/BoardGameTester.java
Solution/BoardGameTester.java
import games.board.*;
import games.ut
ilities.*;
public class BoardGameTester {
    public static void main(String args[]) {
        Board tictactoe=new Board(3,3);
        Board connect_four=new Board(6,7);
        Board mastermind=new Board(5,8);
        tictactoe.setCell(Mark.NOUGHT,1,1);
        connect_four.setCell(Mark.RED,2,2);
        mastermind.setCell(Mark.GREEN, 1, 1);
        System.out.println(tictactoe.toString());
        System.out.println(connect_four.toString());
        System.out.println(mastermind.toString());
 
                FileManager.writeToFileAsync(tictactoe.toString(),"ttt.txt" );
        FileManager.writeToFileAsync(connect_four.toString(), "c4.txt" );
        FileManager.writeToFileAsync(mastermi...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here