-
Notifications
You must be signed in to change notification settings - Fork 0
/
Room.java
36 lines (31 loc) · 978 Bytes
/
Room.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
package com.company;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
* Created by Kevin on 20-Oct-16.
*/
public class Room {
public int id;
public String exits;
public boolean hasAir;
public boolean hasTrap;
public String description;
@Override
private void writeObject(ObjectOutputStream oos) throws IOException {
// default serialization
oos.defaultWriteObject();
// write the object
oos.writeInt(id);
oos.writeChars(exits);
oos.writeBoolean(hasAir);
oos.writeBoolean(hasTrap);
oos.writeChars(description);
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
// default deserialization
ois.defaultReadObject();
location = new Room(ois.readInt(), ois.readChar(), ois.readBoolean(), ois.readBoolean(), ois.readChar());
// ... more code
}
}