collections.hashset
Class Product

java.lang.Object
  extended by collections.hashset.Product

public class Product
extends java.lang.Object

Demonstrates how to override the hashCode and equals methods to test for equality.

Author:
Thomas Rowland

Constructor Summary
Product(int _id, java.lang.String _name, java.lang.String _descr, int _qty, double _price)
           
 
Method Summary
 boolean equals(java.lang.Object o)
          Overridden equals method.
 java.lang.String getDescr()
           
 int getId()
           
 java.lang.String getName()
           
 double getPriceEa()
           
 double getPriceNet()
           
 int getQty()
           
 int hashCode()
          Overridden hashCode method.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Product

public Product(int _id,
               java.lang.String _name,
               java.lang.String _descr,
               int _qty,
               double _price)
Method Detail

hashCode

public int hashCode()
Overridden hashCode method. This method gets called first when this object is being added or removed from the HashSet.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overridden equals method. This method gets called when the hash codes from both objects being compared are equal.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getId

public int getId()

getName

public java.lang.String getName()

getDescr

public java.lang.String getDescr()

getQty

public int getQty()

getPriceEa

public double getPriceEa()

getPriceNet

public double getPriceNet()