The goal of this lab is to practice file I/O and to review designing windows.
In this lab we will revisit the Skeet program from lab 14. This time we will give the program the facility to save the current state of the simulation and reload it later.
The program should work as before but with two changes:
Follow these set-up instructions carefully.
Make a directory for this lab and cd
into it.
First, copy files from the course directory for this lab:
hg clone /cslab/class/csci235/lab16 cd lab16
Then copy from your lab14 directory
AddListener.java
and any other class that
you wrote (you should have written another action listener,
perhaps named something like OkListener.java
.
If you previously modified either Skeet.java
or
Skeets.java
, talk to the instructor about how to make
your version work with this lab.
If you did not do the Skeet lab, copy the files from
/cslab/class/csci235/lab16b/
.
Remember that you will need to include -cp
simulation.jar:.
with both the javac
and
java
commands.
First, discuss with your partner how you can save/store a collection of Skeets. You'll need to decided on a file format/protocol.
SaveListener
Next, finish the SaveListener
class
so that its actionPerformed()
method
puts up a window asking for a filename.
This window should also have a button labelled "Ok" or
the equivalent.
Then write another action listener class which will close that window and do the actual saving.
Finally, in the file Skeets.java
, find the
portion of code that will load a configuration from a file
and fill-in what's missing.
Turn in those source files that you changed with a command such as
/cslab/class/csci235/bin/handin lab16 *.java