implemented capability to save CharacterSheet objects to storage
This commit is contained in:
@@ -2,7 +2,9 @@ package Character;
|
|||||||
|
|
||||||
import Character.Races.*;
|
import Character.Races.*;
|
||||||
|
|
||||||
public class CharacterSheet {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class CharacterSheet implements Serializable {
|
||||||
private String name;
|
private String name;
|
||||||
private int age;
|
private int age;
|
||||||
private int heightFeet;
|
private int heightFeet;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package FileManagement;
|
||||||
|
|
||||||
|
public class ExportPDF {
|
||||||
|
|
||||||
|
public ExportPDF() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package FileManagement;
|
package FileManagement;
|
||||||
|
|
||||||
import javax.swing.text.Document;
|
import java.io.*;
|
||||||
import java.io.File;
|
|
||||||
import Character.*;
|
import Character.*;
|
||||||
|
|
||||||
public class FileManager {
|
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();
|
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.
|
// 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