|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.pdx.cs399J.core.Cereal
public class Cereal
This class represents a box of cereal. It has a name and a price.
| Constructor Summary | |
|---|---|
Cereal(String name,
double price)
Creates a new box of cereal |
|
| Method Summary | |
|---|---|
int |
compareTo(Cereal c2)
Compares two Cereals based on their name |
boolean |
equals(Object o)
Two be consistent with the natural ordering, two Cereals that have the same name, are themselves the
same. |
String |
getName()
Returns the name of this cereal |
double |
getPrice()
Returns the price of this cereal |
int |
hashCode()
Two cereals that are equal must have the same hash code. |
static void |
main(String[] args)
Demonstrates the natural ordering of Cereals by
adding a bunch of cereals to a SortedSet |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Cereal(String name,
double price)
| Method Detail |
|---|
public String getName()
public double getPrice()
public String toString()
toString in class Objectpublic int compareTo(Cereal c2)
Cereals based on their name
compareTo in interface Comparable<Cereal>public boolean equals(Object o)
Cereals that have the same name, are themselves the
same.
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic static void main(String[] args)
Cereals by
adding a bunch of cereals to a SortedSet
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||