-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFLoadGameState.java
54 lines (46 loc) · 1.34 KB
/
FLoadGameState.java
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
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class FLoadGameState {
//TODO: Id laden
// private int id;
private String name;
private Date lastSave;
private int level;
private int points;
/**
* Constructor for objects of class LoadGameState
*/
public FLoadGameState() {
try (BufferedReader reader = new BufferedReader(new FileReader(System.getProperty("user.dir") + "/save/GameSave.txt"))) {
String line;
while ((line = reader.readLine()) != null) {
String[] parts = line.split(",");
name = parts[0];
lastSave = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(parts[1]);;
level = Integer.parseInt(parts[2]);
points = Integer.parseInt(parts[3]);
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
}
// public int getId() {
// return id;
// }
public String getName() {
return this.name;
}
public Date getLastSave() {
return this.lastSave;
}
public int getLevel() {
return this.level;
}
public int getPoints() {
return this.points;
}
}