Createanewpackagenamedgames.utilities. AddapublicclassnamedFileManagerthatcontainsthefollowing methods: public static void writeToFile(String saveState, String fileNa me) { //TODO: Write a string to a...

1 answer below »



  1. Createanewpackagenamedgames.utilities.




  2. AddapublicclassnamedFileManagerthatcontainsthefollowing


    methods:


    public static void writeToFile(String saveState, String fileNa me) {


    //TODO: Write a string to a new file synchronously }


    public static void writeToFileAsync (String saveState, String fileName) {
    //TODO: Write a string to a new file asynchronously


    }




  3. Implement the writeToFile() method using a FileWriter in a try-with-resources block. Make sure you import theiopackage:


    import.java.io.*




    1. Implement the writeToFileAsync() method using a separate thread. Use the following code as a guide:


      new Thread() { public void run(){


      writeToFile(saveState fileName); }


      }.start();




    2. Inthemain()methodoftheBoardGameTesterproject,addthe following code:


      FileManager.writeToFileAsync(ticTacToe.toString(), "ttt.txt");


      FileManager.writeToFileAsync(connectFour.toString(), "c4.txt");


      FileManager.writeToFileAsync(mastermind.toString(), "mm.txt");


      The first argument in each method call should have the name you used for the corresponding Board object. Remember to import the games.utilities package!








package games.board; //import games.utilities.FileManager; public class BoardGameTester { public static void main(String[] args) { // TODO Auto-generated method stub int rows,cols; // variables to store rows and columns for each boars /* * Creating TIC-TAC_TOE Board First * 3 rows and 3 columns * */ rows = 3; cols =3; Board ticTacToe = new Board(rows,cols); //Setting cells in the board randomly for(int r=0;r
Answered Same DayMay 23, 2021

Answer To: Createanewpackagenamedgames.utilities. AddapublicclassnamedFileManagerthatcontainsthefollowing...

Valupadasu answered on May 23 2021
154 Votes
FileManager.java
FileManager.java
package games.utilities;
import java.io.FileWriter;
import jav
a.io.IOException;
public class FileManager {
    public static void writeToFile(String saveState, String fileName) {
        FileWriter fw = null;
        try{
            //fw=new FileWriter(fil...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here