implemented capability to save CharacterSheet objects to storage
This commit is contained in:
@@ -2,7 +2,9 @@ package Character;
|
||||
|
||||
import Character.Races.*;
|
||||
|
||||
public class CharacterSheet {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class CharacterSheet implements Serializable {
|
||||
private String name;
|
||||
private int age;
|
||||
private int heightFeet;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package FileManagement;
|
||||
|
||||
public class ExportPDF {
|
||||
|
||||
public ExportPDF() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package FileManagement;
|
||||
|
||||
import javax.swing.text.Document;
|
||||
import java.io.File;
|
||||
import java.io.*;
|
||||
|
||||
import Character.*;
|
||||
|
||||
public class FileManager {
|
||||
@@ -14,12 +14,39 @@ public class FileManager {
|
||||
|
||||
}
|
||||
|
||||
public CharacterSheet readCharacter() {
|
||||
|
||||
// TODO: Need to implement. Reads file and returns a re-created CharacterSheet object.
|
||||
public CharacterSheet readCharacter(int index) {
|
||||
|
||||
File character = savedCharacters[index];
|
||||
|
||||
return new CharacterSheet();
|
||||
|
||||
}
|
||||
|
||||
public void saveCharacter (CharacterSheet completedCharacter) {
|
||||
|
||||
try {
|
||||
|
||||
FileOutputStream fileOut =
|
||||
new FileOutputStream("/bin/" + completedCharacter.getName().hashCode() + ".dnd");
|
||||
ObjectOutputStream out = new ObjectOutputStream(fileOut);
|
||||
out.writeObject(completedCharacter);
|
||||
out.close();
|
||||
fileOut.close();
|
||||
|
||||
} catch (IOException i) {
|
||||
|
||||
i.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to implement.
|
||||
public void deleteCharacter(int index) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to implement. Should create an array of Files corresponding to user-created characters.
|
||||
@@ -27,14 +54,6 @@ public class FileManager {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void saveCharacter (Character completedCharacter) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user