CS 112 Project 3
University Database
Due Friday, Feb. 22nd 2008
(adapted from Chris Brooks)

Description

In this project, you will write a program that does the following:

The first command-line parameter to your program is the file to read from, the second command-line parameter is the file to write to.

Required Classes

In this project, you'll be working with data for three types of individuals: Undergraduates, Graduate Students, and Professors.

You should start by creating an abstract base class called Person. Person should have the following instance variables, which should all be protected :

In addition to setters and getters, Person should have two constructors (one that takes zero arguments and one that takes three), and an abstract method called toXML().

You should then create three subclasses of Person: Undergrad, GradStudent, and Professor. Undergrads and GradStudents have two additional instance variables: GPA and Major. They should also implement toXML().

Professors should have one additional instance variable: Department. They should also implement toXML().

All of these derived classes should also implement the Comparable interface.  An explaination of how the compareTo method should behave is in the Sortring Rules section below.

File Formats

The original data file is in the following format:

Undergrad: Frederick   Dilallo : 89136171 : 4/7/1983 : 2.63 : Communication Studies
Grad Student: Amy Bunche : 85469658 : 8/2/1979 : 3.46 : History
Professor: Allen Claeys : 91419913 : 5/5/1955 : African Studies

Notice that colons are used to separate the fields.

And the XML should be in the following format:

<people>
<undergrad>
<name> Frederick Dilallo </name>
<id> 89136171 </id>
<dateOfBirth> 4/7/1983 </dateOfBirth>
<gpa> 2.63 </gpa>
<major> Communication Studies </major>
</undergrad>
<grad>
<name> Amy Bunche </name>
<id> 85469658 </id>
<dateOfBirth> 8/2/1979 </dateOfBirth>
<gpa> 3.46 </gpa>
<major> History </major>
</grad>
<professor>
<name> Allen Claeys </name>
<id> 91419913 </id>
<dateOfBirth> 5/5/1955 </dateOfBirth>
<department> African Studies </department>
</professor>
</people>

Whitespace (outside of items) is not terribly important for XML.  You should use end-of-line characters as noted above to make your output somewhat human readable, but you do not need to indent sub-elements when printing out XML.    Note that you will also need to do some work to get the name in a nicer format (that is, no extra spaces between the first and last name)


Following is a web-based form that will generate random lists of people for testing:


How many people do you want generated?


You should read in people one entry at a time and insert them into a sorted list.  Note that for Project 1 you created an ordered list of Strings -- you can easily modify that project so that it handles a list of any Comparable object instead of just strings. 

Sorting Rules

You should use the following rules to sort people:

Grading

Submission

All file(s) required for your project should be in the folder https://www.cs.usfca.edu/svn/<username>/cs112/Project3/