/*
 * File: NameSurferEntry.java
 * --------------------------
 * This class represents a single entry in the database.  Each
 * NameSurferEntry contains a name and a list giving the popularity
 * of that name for each decade stretching back to 1900.
 */

import acm.util.*;
import java.util.*;

public class NameSurferEntry implements NameSurferConstants {

/* Constructor: NameSurferEntry(line) */
/**
 * Creates a new NameSurferEntry from a data line as it appears
 * in the data file.  Each line begins with the name, which is
 * followed by integers giving the rank of that name for each
 * decade.
 */
	public NameSurferEntry(String line) {
		// You fill this in //
	}

/* Method: getName() */
/**
 * Returns the name associated with this entry.
 */
	public String getName() {
		// You need to turn this stub into a real implementation //
		return null;
	}

/* Method: getRank(decade) */
/**
 * Returns the rank associated with an entry for a particular
 * decade.  The decade value is an integer indicating how many
 * decades have passed since the first year in the database,
 * which is given by the constant START_DECADE.  If a name does
 * not appear in a decade, the rank value is 0.
 */
	public int getRank(int decade) {
		// You need to turn this stub into a real implementation //
		return 0;
	}

/* Method: toString() */
/**
 * Returns a string that makes it easy to see the value of a
 * NameSurferEntry.
 */
	public String toString() {
		// You need to turn this stub into a real implementation //
		return "";
	}
}


@@ -1,8 +1,9 @@
+%0A
 /*%0A * Fi
@@ -261,18 +261,27 @@
 ort 
-acm
+java
 .util.
-*
+ArrayList
 ;%0Aim
@@ -295,17 +295,20 @@
 va.util.
-*
+List
 ;%0A%0Apubli
@@ -368,54 +368,81 @@
 s %7B%0A
-%0A/* Constructor: NameSurferEntry(line) */%0A
+    private List%3CInteger%3E decades;%0A    private String name;%0A%0A    
 /**%0A
+    
  * C
@@ -500,19 +500,16 @@
  appears
-%0A *
  in the 
@@ -516,15 +516,21 @@
 data
+%0A     *
  file.
- 
  Eac
@@ -566,19 +566,16 @@
 which is
-%0A *
  followe
@@ -587,16 +587,23 @@
 integers
+%0A     *
  giving 
@@ -632,19 +632,16 @@
 for each
-%0A *
  decade.
@@ -642,20 +642,27 @@
 ecade.%0A 
-*/%0A%09
+    */%0A    
 public N
@@ -695,65 +695,270 @@
 ) %7B%0A
-%09%09// You fill this in //%0A%09%7D%0A%0A/* Method: getName() */%0A/**%0A
+        String%5B%5D splitLine = line.split(%22%5C%5Cs+%22);%0A        name = splitLine%5B0%5D;%0A%0A        decades = new ArrayList%3CInteger%3E();%0A        for (int i = 1; i %3C splitLine.length; i++) %7B%0A            decades.add(Integer.parseInt(splitLine%5Bi%5D));%0A        %7D%0A    %7D%0A%0A    /**%0A    
  * R
@@ -998,28 +998,35 @@
 his entry.%0A 
-*/%0A%09
+    */%0A    
 public Strin
@@ -1043,123 +1043,48 @@
 ) %7B%0A
-%09%09// You need to turn this stub into a real implementation //%0A%09%09return null;%0A%09%7D%0A%0A/* Method: getRank(decade) */%0A/**%0A
+        return name;%0A    %7D%0A%0A    /**%0A    
  * R
@@ -1144,19 +1144,16 @@
 ular
-%0A *
  decade.
   Th
@@ -1152,13 +1152,19 @@
 ade.
- 
  The
+%0A     *
  dec
@@ -1206,19 +1206,16 @@
 how many
-%0A *
  decades
@@ -1232,16 +1232,23 @@
 ed since
+%0A     *
  the fir
@@ -1271,19 +1271,16 @@
 atabase,
-%0A *
  which i
@@ -1302,16 +1302,23 @@
 constant
+%0A     *
  START_D
@@ -1323,17 +1323,16 @@
 _DECADE.
- 
  If a na
@@ -1338,19 +1338,16 @@
 ame does
-%0A *
  not app
@@ -1385,20 +1385,27 @@
  is 0.%0A 
-*/%0A%09
+    */%0A    
 public i
@@ -1433,115 +1433,135 @@
 ) %7B%0A
-%09%09// You need to turn this stub into a real implementation //%0A%09%09return 0;%0A%09%7D%0A%0A/* Method: toString() */%0A/**%0A
+        if (decade %3C decades.size()) %7B%0A            return decades.get(decade);%0A        %7D%0A%0A        return 0;%0A    %7D%0A%0A    /**%0A    
  * R
@@ -1617,16 +1617,20 @@
 ue of a%0A
+    
  * NameS
@@ -1646,12 +1646,33 @@
 y.%0A 
-*/%0A%09
+    */%0A    @Override%0A    
 publ
@@ -1698,85 +1698,66 @@
 ) %7B%0A
-%09%09// You need to turn this stub into a real implementation //%0A%09%09return %22%22;%0A%09
+        return String.format(%22%25s %25s%22, name, decades);%0A    
 %7D%0A%7D%0A
-%0A

Implement assignment 6 milestone 2