|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object LetterInventory
public class LetterInventory
A LetterInventory object represents the count of each letter A-Z found in a given String.
Constructor Summary | |
---|---|
LetterInventory(java.lang.String s)
Constructs a letter inventory to count the letters in the given string. |
Method Summary | |
---|---|
void |
add(LetterInventory other)
Adds the letters in the given inventory to those in this one. |
void |
add(java.lang.String s)
Adds the letters in the given string to those in this inventory. |
int |
compareTo(LetterInventory other)
Compares this inventory to the given other one by the alphabetical order of their toString representations. |
boolean |
contains(LetterInventory other)
Returns true if this inventory contains all of the letters in the given inventory in at least as large of a count. |
boolean |
contains(java.lang.String s)
Returns true if this inventory contains all of the letters in the given string in at least as large of a count. |
boolean |
equals(java.lang.Object o)
Returns whether o refers to a LetterInventory object with equal counts of letters to this LetterInventory. |
boolean |
isEmpty()
Returns whether there are no letters in this inventory. |
int |
size()
Returns the total number of letters in this inventory. |
void |
subtract(LetterInventory other)
Removes the letters in the given inventory from this one. |
void |
subtract(java.lang.String s)
Removes the letters in the given string from this one. |
java.lang.String |
toString()
Returns a string representation of this inventory, such as "[ehhhillo]". |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public LetterInventory(java.lang.String s)
s
- The string to inventory.
java.lang.NullPointerException
- if the string passed is null.Method Detail |
---|
public void add(LetterInventory other)
other
- the inventory to add.
java.lang.NullPointerException
- if the inventory passed is null.public void add(java.lang.String s)
s
- the string to add.
java.lang.NullPointerException
- if the string passed is null.public int compareTo(LetterInventory other)
toString
representations.
In other words, [bbcfy] < [bdfy] < [gil] < [xyz].
compareTo
in interface java.lang.Comparable<LetterInventory>
other
- the inventory to compare against.
java.lang.NullPointerException
- if the inventory passed is null.public boolean contains(LetterInventory other)
other
- The other inventory to examine.
java.lang.NullPointerException
- if the inventory passed is null.public boolean contains(java.lang.String s)
s
- The string to examine.
java.lang.NullPointerException
- if the string passed is null.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the object to compare against.
public boolean isEmpty()
public int size()
public void subtract(LetterInventory other)
other
- the inventory to subtract.
java.lang.IllegalArgumentException
- if the letters in the other inventory
are not contained in this one.
java.lang.NullPointerException
- if the inventory passed is null.public void subtract(java.lang.String s)
s
- the string to subtract.
java.lang.IllegalArgumentException
- if the letters in the string
are not contained in this one.
java.lang.NullPointerException
- if the string passed is null.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |