-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDungeonGame.java
More file actions
43 lines (34 loc) · 822 Bytes
/
DungeonGame.java
File metadata and controls
43 lines (34 loc) · 822 Bytes
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
import java.io.*;
class DungeonGame implements Serializable {
public int x = 3;
transient long y = 4;
private short z = 5;
int getX() {
return x;
}
long getY() {
return y;
}
short getZ() {
return z;
}
}
class DungeonTest {
public static void main(String[] args) {
DungeonGame d = new DungeonGame();
System.out.println(d.getX() + d.getY() + d.getZ());
try {
FileOutputStream fos = new FileOutputStream("dg.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(d);
oos.close();
FileInputStream fis = new FileInputStream("dg.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
d = (DungeonGame) ois.readObject();
ois.close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(d.getX() + d.getY() + d.getZ());
}
}