Due: Thursday, December 19 9:50am
Changed the due date from December 16 9:50am to Thursday, December 19 9:50am (Note: Morning 9:50).
There’s an issue with the sex of the name. Solution: In the generateStats method, maintain 2 TreeMaps, one for males and one for females. As you read the datafiles, you know which sex your dealing with; add it to the appropriate TreeMap.
Because this is an important, substantial assignment, it will count as two homework assignments.
The final homework assignment will be a rewrite of the name application V1.0. V1.0 had serious performance problems and buyers of the product want their money back.
V1.0 used an ArrayList to build the name 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. Read Chapter 27 for a theoretical background on Sets and Maps.
Hints and Tips:
- DO NOT MODIFY THE NAME CLASS!!! No Need.
- In the NameStats class, change the names fields to be of type TreeMap<String, Integer>.
- Incorporate into your app: Supplement Code for Names App V2.0
- Do most of your coding in the generateStats method. Create a local names TreeMap and load this map 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 in the supplemental code that generates value ordered entries on the local TreeMaps and store the new map in the names class field.
- Do not remove the concept of an ArrayList<Name> from V2. In the getTopNames method have it still return an ArrayList<Name>. Use code in the supplement to load the Arraylist with the top Names:
- Keep all the other code intact and watch V2.0 fly!