CSC-220 HW9 Babyname V2.0 Application

Due:  Monday, December 17 9:50am

This represents the last minute this course is legally open.  No submissions afterward.

The final homework assignment will be a complete rewrite of the babyname application.  V1.0 had serious performance problems and buyers of the product want their money back.

V1.0 used an ArrayList to build the babyname counts.  V2.0 is going to scrap that design and use a data structure called a TreeMap.

Read Chapter 21 Sets and Maps to get a handle on the built in Collections Data Structure available in standard Java.

Hints and Tips (Friday 12/7): 

After producing a working V2.0 that is substantially faster than V1.0, I want to share my thoughts to help you code your assignment.

  • DO NOT DELETE THE BABYNAME CLASS!!!  I was wrong in my initial assessment of the project. Keep the class as is.  Do not change it at all.
  • In the BabyNameStats class, change the boys and girls fields to be of type TreeMap<String, Integer>.
  • Add this code to your class.  It sorts the TreeMap entries by the value field.  It uses a Comparator object to do the sorting.  https://pastebin.com/2Jkt0g6m 
  • Do most of your coding in the generateStats method.  Create local boys and girls TreeMaps and load the TreeMaps with names and counts.  The problem is the normal TreeMap with no Comparator orders the entries by key which is the name.  We really need to have them ordered by value which is the count.  Call the method that generates value ordered entries on the local TreeMaps and store the new maps in the boys and girls class fields.
  • Do not remove the concept of an ArrayList<BabyName> from V2.  I was a bit over zealous about removing it entirely.  In the getTopNames method have it still return an ArrayList<BabyName>.  But this time use this code to load the Arraylist with the top BabyNames: https://pastebin.com/SgJAQZ1U
  • Keep all the other code intact and watch V2.0 fly!