Class DomainPersistency
java.lang.Object
nz.ac.vuw.ecs.swen225.gp6.persistency.DomainPersistency
This utility class is responsible for saving and loading classes in the Domain package.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleandelete(int slot) Delete a saved game from a slot.static MazeCreate a fallback maze to be used when the level files cannot be read.static DomainGet the initial domain object.static DomainloadSave(int slot) Load a saved game from a slot.static voidSave a domain object to a save slot.
-
Method Details
-
fallbackMaze
Create a fallback maze to be used when the level files cannot be read. As this maze is more basic than the default maze, it should only be used as a fallback.- Returns:
- The fallback maze
-
loadSave
Load a saved game from a slot. The associated file exists in res/saves/[slot].xml- Parameters:
slot- The slot to load from- Returns:
- The loaded domain
- Throws:
org.dom4j.DocumentException- If the XML document is malformed
-
delete
Delete a saved game from a slot. The associated file in res/saves/[slot].xml is deleted.- Parameters:
slot- The slot to delete- Returns:
- True if the save was deleted, false otherwise
- Throws:
IOException- If the file could not be deleted
-
getInitial
Get the initial domain object. It contains all levels found in res/levels.- Returns:
- The initial domain
-
save
Save a domain object to a save slot. The associated file exists in res/saves/[slot].xml- Parameters:
domain- The domain to saveslot- The save slot to save to- Throws:
IOException- If the file could not be written
-