Assignment #5: Serialization

A Person class is declared as follows:
            public class Person
            {
                public Person( String n, String d )
                {
                    name = n;
                    birthDate = d;  // such as Jan 5, 2001
                }
                
                public String toString( )
                {
                    return "Person: " + name + " " + birthDate;
                }
                
                private String name;
                private String birthDate;
            }
  1. Write a program, Assign5a, that constructs five different Person objects, places them in a List, and then serializes the result to a file specified by either a command line argument or user input (your choice). Of course, you will need to slightly alter Person to do this. Run Assign5a, twice, sending the result first to out5a.ser and then to out5b.ser.
  2. Write a program Assign5b, that reads files that contains a serialized list of Person objects and prints the list. The files are specified by either a command line argument or user input (your) choice. Run Assign5b once, using both out5a.ser and out5b.ser.
  3. The Person class changes. Change the private birthDate field to an object of type Date, and change the implementation of the Person constructor accordingly. The signature of the constructor is not to change, nor is the name of the field birthDate. (Note: in both versions, an unknown birthdate is represented by null). Change the implementation of toString to indicate that this is the revised Person class, but otherwise make no changes. The main part of the assignment is to revise the Person class in such a way, so that if you rerun Assign5a to regenerate out5b.ser using the new Person format, BUT LEAVE out5a.ser IN THE OLD FORMAT, you will still be able to run Assign5b as was done before, even though there are two different Person formats. In implementing this part, you may rewrite and recompile only class Person.

What to Submit

Submit your source code, with the new version of Person and output that illustrates that you have done this correctly.