Answered You can hire a professional tutor to get the answer.
Need help with this! /** * Class to handle loading and saving of data * * You must write 4 methods * * loadMineField - loads mine field definition *
Need help with this!
/**
* Class to handle loading and saving of data
*
* You must write 4 methods
*
* loadMineField - loads mine field definition
*
* saveMineField - saves minefield
*
* Here the only concern is loading/saving a mine field definition file where -1
* denotes a mine, and any non-negative number is safe.
*
* saveGame - saves the entire game state
*
* loadGame - loads the game state
*
* For a game we need both the mines and the exposed array data. Unfortunately
* the given MineField class (which you cannot change) does not provide a way to
* set that.
*
* Take a look at documentation for MineFieldIO and see if you can think of a
* way to use that shell class to help you.
*
*
* @author <student>
* @version 0
*
*/
public class MineFieldFileIO {
/**
* Saves a mine field definition to a file (You decide the format)
*
* @param mf
* - reference to a mine field
* @param fileName
* - string to path to minefield
* @return true if successfully saved, false otherwise
*
*/
public static boolean saveMineFile(MineField mf, String fileName) {
// @todo - fix this
return false;
}
/**
* Reads the minefield definition from a file format of your choosing.
*
* A complete minefield with initialized hints and exposed array should be
* returned.
*
* Throws a MineFieldException if the file is opened, but the data is
* invalid.
*
* Valid games should have at least 1 mine, and at least one empty cell.
*
* @param fileName
* - string to path to minefield
* @return valid instance to minefield instance or null if file has
* IOException
* @throw invalid MineFieldException if data in file is invalid for any
* reason other than IOException
*/
public static MineField readMineFile(String fileName) {
// @todo - fix this
return null;
}
/**
*
* Saves the current game state to file including both minefield and current
* exposed array information.
*
* The format is of your choosing.
*
* @param mineField
* - reference to a mine field
* @param fileName
* - string to path to minefield
* @return true if successfully saved, false otherwise
*
*/
public static boolean saveMineSweeperGame(MineField mineField,
String fileName) {
// @todo - fix this
return false;
}
/**
* Reads the saved game state, both field and exposed status, from a file
* format of your choosing.
*
* A complete minefield with initialized hints and exposed array should be
* returned.
*
* Throws a MineFieldException if the file is read, but the data is invalid.
*
* Valid games should have at least 1 mine, at least one empty cell, and at
* least 1 unexposed cell that is either a 0 or hint.
*
* @param fileName
* - string to path to minefield
* @return valid instance to minefield instance or null if file has
* IOException
* @throw invalid MineFieldException if data is invalid for any reason other
* than a file IOException
*/
public static MineField readMineSweeperGame(String fileName) {
// @todo - fix this
return null;
}
}