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