Popular Names Grapher
Against all bureaucratic stereotypes, the Social Security Administration, provides a neat web site showing the distribution of names chosen for kids over the last 100 years in the US. Every 10 years, the data gives the 1000 most popular boy and girl names for kids born in the US. The data can be boiled down to a single text file as shown below. On each line we have the name, followed by the rank of that name in 1900, 1910, 1920, ... 2000 (11 numbers). A rank of 1 was the most popular name that year, while a rank of 997 was not very popular. A 0 means the name did not appear in the top 1000 that year at all. The elements on each line are separated from each other by a single space.
... Sam 58 69 99 131 168 236 278 380 467 408 466 Samantha 0 0 0 0 0 0 272 107 26 5 7 Samara 0 0 0 0 0 0 0 0 0 0 886 Samir 0 0 0 0 0 0 0 0 920 0 798 Sammie 537 545 351 325 333 396 565 772 930 0 0 Sammy 0 887 544 299 202 262 321 395 575 639 755 Samson 0 0 0 0 0 0 0 0 0 0 915 Samuel 31 41 46 60 61 71 83 61 52 35 28 Sandi 0 0 0 0 704 864 621 695 0 0 0 Sandra 0 942 606 50 6 12 11 39 94 168 257 ...
We see that "Sam" was #58 in 1900 and is slowly moving down. "Samantha" popped on the scene in 1960 and is moving up strong to #7. "Samir" barely appears in 1980, but by 2000 is up to #798. Ultimately, we want to graph each name's popularity as a bar graph.
We will use the following files in today's activity:
You will be updating the first three classes, the last one simply starts the program (you will not need to update it). You can use Eclipse to download these files to your machine by choosing the classwork project named namesurfer. When compiled and run, it should display an almost empty window.
To make the program work, complete the following methods:
- Complete the accessor methods,
getNameandgetRank, for theNameRecordclass. - Complete the constructor for the class
NameRecord. -
Complete the constructor for the class
NameDatabase. - Complete the
matchmethods for theNameRecordclass, then theNameDatabaseclass. - Complete the
getPercentmethod for theCanvasclass.