Hand in via Moodle as Person.java and PeopleSorter.java
OK, 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, please consider a person's "age" to be their age on Dec 31, 2018. (This means you don't have to figure out how to get Java to tell you today's date, and the graders will be able to test your code easily.)
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 are more object-oriented approaches to PeopleSorter that don't depend on static methods. We'll discuss these in class after you've completed this assignment.
Start early, ask questions, and have fun!