|
|
|
@ -130,12 +130,19 @@ public class GameModel {
|
|
|
|
|
|
|
|
|
|
public void save() {
|
|
|
|
|
File file = new File("F:\\bingor\\temp\\tank.data");
|
|
|
|
|
ObjectOutputStream oos = null;
|
|
|
|
|
try {
|
|
|
|
|
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
|
|
|
|
|
oos = new ObjectOutputStream(new FileOutputStream(file));
|
|
|
|
|
oos.writeObject(myTank);
|
|
|
|
|
oos.writeObject(gameObjects);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
try {
|
|
|
|
|
oos.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -148,6 +155,12 @@ public class GameModel {
|
|
|
|
|
gameObjects = (List<GameObject>) ois.readObject();
|
|
|
|
|
} catch (IOException | ClassNotFoundException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
try {
|
|
|
|
|
ois.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|