java.lang.ObjectNameCount
public class NameCount
NameCount represents a famous name and its frequency of occurrence. NameCounts are ordered alphabetically.
Constructor Summary | |
---|---|
NameCount()
A NameCount is constructed with an empty FamousName, a count of zero. |
|
NameCount(FamousName name,
Natural frequency)
A NameCount is constructed from the provided FamousName, and the provided frequency count. |
|
NameCount(java.lang.String name)
A NameCount is constructed from the provided String and a count of zero. |
Method Summary | |
---|---|
int |
compareTo(NameCount other)
Compares this NameCount with the provided NameCount. |
boolean |
equals(java.lang.Object other)
Compare two NameCounts for equality. |
Natural |
getCount()
Get the frequncy count from this NameCount. |
void |
increment()
Increment the count by 1. |
java.lang.String |
toString()
Return a formatted string representation of this NameCount. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NameCount()
public NameCount(java.lang.String name)
name
- the name of this famous personpublic NameCount(FamousName name, Natural frequency)
name
- the name of this famous personfrequency
- the number of times this name occursMethod Detail |
---|
public Natural getCount()
public void increment()
public int compareTo(NameCount other)
compareTo
in interface java.lang.Comparable<NameCount>
other
- NameCount to which this NameCount is to be compared.
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- the other NameCount to compare against
public java.lang.String toString()
toString
in class java.lang.Object