You are going to create a family history program that will exercise your ability to work with collections. This lab will be due on Monday and Tuesday, Dec 6,7 in order to give you time to pass off late labs on Wednesday and Thursday.
You will write a program that performs the following functions:
Program Flow:
Each line will look something like this.
FirstName LastName Identifier FatherIdentifier MotherIdentifier BirthYear BirthCity, BirthState, BirthCountry
So data for the Bush family might look like
George Bush 016873 001244 001243 1946 New Haven, Connecticut, USA George Bush 001244 000364 000367 1924 Milton, Massachusetts, USA Barbara Pierce 001243 000372 000298 1925 New York City, New York, USA Jed Bush 07465 001244 001243 1947 Miami, Florida, USA Mary Bush 17309 001244 001243 1948 Provo, Utah, USA Martin Frank 99934 88845 17309 1968 Kanab, Utah, USA Gary Haws 77745 99934 66623 1988 Nephi, Utah, USA Margie Smith 000367 111023 111024 1926 Orem, Utah, USA John Bush 000364 211023 211024 1927 Eugene, Oregon, USA Wilma Flinstone 211024 311023 311876 1907 Sacramento, California, USA
You can give the URL Bushfor this data to your program for initial testing, but you will want to create some additional test cases. Notice a few things:
Compile and run your program from the command line. Some command line tips (Under Construction) FamilyHistory
Use the toString() method on your ArrayList of people. Your Person class should have a reasonable toString() method. Meaning, you shouldn't just regurgitate the line that created the person.
Print out the people grouped by birth year by using the ArrayList peoplelist.toString() method to call the toString method on each Person. You should group them by making the person class implement the “Comparable” interface, and sort your ArrayList using this comparable interface. You may want to look at Arrays.sort() (for a plain array) or Collections.sort() (for an ArrayList)
Put all of your people into a map based on the person ID. Then go through each of your Person objects, look up the father and mother ID in the map and assign the object you find in the map to private Person variables in the child object. By so doing, you will have created a tree with your Person referencing the two parents.
Allow the user to enter a last name. Print the names and identifiers of those who have that last name.
Allow the user to input an identifier and print out the pedigree for that person. For example, if the user selected identifier 016873 from our sample data, then the following pedigree would be printed. You may want to create a more intuitive output format, but this will do if you cant think of anything else.
016873 George Bush - George Bush -- John Bush --- Wilma Flinstone -- Margie Smith - Barbara Pierce
Now print the family group sheet where that same person (016873 George Bush) appears as a child. Again, you are free to choose another format if you want to.
Father: George Bush Birth: 1924 Milton, Massachusetts, USA Mother: Barbara Pierce Birth: 1925 New York City, New York, USA Children: George Bush Birth: 1946 New Haven, Connecticut, USA Jed Bush Birth: 1947 Miami, Florida, USA Mary Bush Birth: 1948 Provo, Utah, USA
You should create some test cases (you can put them into your public_html folder in order to make them available through a URL). The TA will evaluate your program with data sets that are similar to those found here ://dna.cs.byu.edu/cs142/families.html.
The following grading criteria will be used:
5 points extra credit: format the pedigree chart in a better way.
Extra Credit: Pass off early (1 point per day (excluding Sunday) up to 3 points)