Question: I need help please to edit and change the bottom code to the new version below Create a new version of your Monster Attack lab,

I need help please to edit and change the bottom code to the new version below

Create a new version of your Monster Attack lab, but add binary file I/O and a JavaFX GUI to take the input and provide output.

1) Use an interface called MonsterPersister that includes a method to save a list of MonsterAttacks to a file and one to read a list of MonsterAttacks from a file and return the list.

2) Implement the interface with the class BinaryMonsterPersister, which uses binary file I/O.

3) Implement the interface again with the class TextMonsterPersister, which uses the text file I/O method you already created.

4) Let the user choose at runtime whether to use binary or text I/O.

5) Use JavaFX, not Swing, for the GUI. You may choose to use either all-Java coding or FXML for the UI

/************************************************************************************************************************************************/

package Monster;

import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Scanner;

public class AttackMonitor { static Scanner input = new Scanner(System.in); private List x = new ArrayList();

public void menuChoice() { int choice = 0; System.out.println("Enter your choice"); do { System.out.print( "0) Quit " + "1) List the attack from the text file " + "2) Enter new attack into the File"); choice = input.nextInt(); switch (choice) { case 0: System.out.println("Program exit now."); System.exit(0); break; case 1: readTheFile(); break; case 2: addToTextFile(); break; }

} while (choice != 0); }

private void readTheFile() { String nameofFile = ""; input.nextLine(); System.out.print("Please enter the name of the file:\t"); nameofFile = input.nextLine(); BufferedReader file = null; String monster = "", separate = ","; try { file = new BufferedReader(new FileReader(nameofFile)); while ((monster = file.readLine()) != null) { String[] attack = monster.split(separate); System.out.println(attack[0] + attack[1] + attack[2] + attack[3] + attack[4]); } } catch (Exception ex) { System.err.println(ex); } }

private void addToTextFile() { String fileOut = "", location = ""; int attackId = 0; System.out.print("Please the name of the file for save: in (.txt) format!\t"); input.nextLine(); fileOut = input.nextLine();

File fileNameOut = new File(fileOut); PrintWriter outFile = null; String date = "", Attack = "", reporter = ""; try { outFile = new PrintWriter(fileNameOut); System.out.print("Please enter the id\t"); attackId = input.nextInt(); System.out.print(" Please enter the date of attacked, in format \"MM/DD/YYYY\"):\t"); date = input.next(); input.nextLine(); System.out.print(" Please enter the name of attacked:\t"); reporter = input.nextLine(); System.out.print(" Please enter the location of the attacked:\t"); location = input.nextLine(); System.out.print(" Please enter the name of reporter:\t"); reporter = input.nextLine(); x.add(new MonsterAttack(attackId, date, Attack, location, reporter)); outFile.println("Attack #, " + attackId + ",: " + Attack + " attacked " + location + " on, " + date + ",. Reported by " + reporter + "."); } catch (Exception ex) {

} outFile.close();

}

} /*********************************************************************************************************************************************/

package Monster;

public class MonsterAttack { private int Id; private String Moster; private String location; private String name; private int month; private int day; private int year;

public MonsterAttack(int IdA, String dateA, String nameMonsterA, String locationA, String nameA) { Id = IdA; name = nameA; Moster = nameMonsterA; location = locationA; String[] MonthDayYear = dateA.split("/", 0); month = Integer.parseInt(MonthDayYear[0]); day = Integer.parseInt(MonthDayYear[1]); year = Integer.parseInt(MonthDayYear[2]); }

public int getId() { return Id; }

public void setId(int Id) { this.Id = Id; }

public int getMonth() { return month; }

public void setMonth(int month) { this.month = month; }

public int getDay() { return day; }

public void setDay(int day) { this.day = day; }

public int getYear() { return this.year; }

public void setYear(int year) { this.year = year; }

public String getMonster() { return Moster; }

public void setMonster(String Monster) { this.Moster = Monster; }

public String getLocation() { return location; } public void setLocation(String location) { this.location = location; }

public String getName() { return name; }

public void setName(String name) { this.name = name; }

public String toString() { return "Attact # " + Id + ": " + Moster + " attacted " + location + " on " + month + "/" + day + "/" + year + ". Reported by " + name + "."; } } /*********************************************************************************************************************************/

package Monster; public class MonsterAttackDriver {

public static void main(String[] args) { AttackMonitor x = new AttackMonitor(); x.menuChoice(); } }

something like this attachment I need help please to edit and change the bottom code to

Monsters File Open Add Monster Save Exit Hometown Rampage Behavior tdg tghdhtgitgh Name ssotgdtgs dtgtdgdt.. Idgtsdg

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!