-
Notifications
You must be signed in to change notification settings - Fork 0
/
savedatapseudocode.txt
63 lines (46 loc) · 1.64 KB
/
savedatapseudocode.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class SaveData {
private static File saveGameNames = new File("saveGameNames.txt")
private File saveFile;
private src.actor.PlayerChar character;
public SaveData(src.actor.PlayerChar character) {
this.character = character;
}
public static void saveGame(File, src.actor.Character, Game){
println("Choose which file to save to: ")
String saveGame = chooseSaveFile();
save src.actor.Character.name
save src.actor.Character.inventory
save src.actor.Character.stats
save game data
}
public File loadGame() {
this.saveFile = chooseSaveFile();
FileReader fr = new FileReader(this.saveFile)
inventory = read file
stats = read file
gamestate = read file
new src.actor.Character(name, inventory, stats, gamestate)
}
private static File chooseSaveFile(){
Scanner sc = new Scanner(saveGameNames)
arrayList<String> saveNamesArray = new ArrayList<>()
saveNamesArray.add("0: New File")
i = 1;
while(sc.hasNextLine()) {
saveNamesArray.add(String.format(%d: %s", i, sc.nextLine())
i++
}
println("Choose which file to load: ")
saveNamesArray.foreach(n -> println("\t" + n)
while {
try {
get int chosenSave as input
String saveName = saveNamesArray.get(chosenSave)
break;
} catch index error {
println("Save file does not exist! Please choose one of the options listed above:")
}
}
return new File(saveName + ".txt")
}
}