57 lines
1.3 KiB
Java
57 lines
1.3 KiB
Java
package set;
|
|
|
|
import java.util.*;
|
|
import bytecodeAnnotations.*;
|
|
|
|
/**
|
|
* An item with a description and a part number.
|
|
* @version 1.01 2012-01-26
|
|
* @author Cay Horstmann
|
|
*/
|
|
public class Item
|
|
{
|
|
private String description;
|
|
private int partNumber;
|
|
|
|
/**
|
|
* Constructs an item.
|
|
* @param aDescription the item's description
|
|
* @param aPartNumber the item's part number
|
|
*/
|
|
public Item(String aDescription, int aPartNumber)
|
|
{
|
|
description = aDescription;
|
|
partNumber = aPartNumber;
|
|
}
|
|
|
|
/**
|
|
* Gets the description of this item.
|
|
* @return the description
|
|
*/
|
|
public String getDescription()
|
|
{
|
|
return description;
|
|
}
|
|
|
|
public String toString()
|
|
{
|
|
return "[description=" + description + ", partNumber=" + partNumber + "]";
|
|
}
|
|
|
|
@LogEntry(logger = "com.horstmann")
|
|
public boolean equals(Object otherObject)
|
|
{
|
|
if (this == otherObject) return true;
|
|
if (otherObject == null) return false;
|
|
if (getClass() != otherObject.getClass()) return false;
|
|
Item other = (Item) otherObject;
|
|
return Objects.equals(description, other.description) && partNumber == other.partNumber;
|
|
}
|
|
|
|
@LogEntry(logger = "com.horstmann")
|
|
public int hashCode()
|
|
{
|
|
return Objects.hash(description, partNumber);
|
|
}
|
|
}
|