OK, so did you learn everything there is to know about Java? Maybe not, but let's take it out for a spin anyway.
For this assignment, you will write a program that reads from a text file representing a sequence of people. Your program will need to convert the text file data into an ArrayList<Person>, sort the ArrayList, and print the list out in alphabetical order. This will give you practice working with ArrayList, String, File, Scanner, loops, and simple classes.
Use moodle to submit a single zip file containing two Java files: Person.java containing the simple Person class, and PeopleSorter.java containing a main method and any supporting methods you find useful. See below for some suggestions
Each line of the input file will represent a single person via a comma-delimited list, like so:
or, for example:
Your main method should be structured so that the program expects a single command-line argument specifying the path of the input file. Thus, I would be able to run your program like so:
if I had a properly formatted text file called people.txt in the same directory as Person.java, or
if morepeople.txt was in a subdirectory called "data".
Your program should print to standard output (i.e. System.out) one person per line, alphabetized by family name (then given name in case of identical family names, then year of birth in case of identical names). Each line of output should look like:
for example:
For the purposes of this assignment, you may consider a person's "age" to be his/her/its age on Dec 31, 2013. If you want an extra challenge, of course, you should feel free to explore Java's built-in date-handling libraries.
Keep modularity in mind as you design your code, providing methods to encapsulate the main services you want from your Person objects. For example, you might organize your Person class like so:
A static-method-only approach to PeopleSorter might look like this. The point here is to put major self-contained operations into separate methods. This way, the main program reads like a high-level outline of
There's a more object-oriented approach to PeopleSorter that doesn't depend on static methods. I'll show you that in class if there's time.
Start early, ask lots of questions, and have fun!