/**
* Comparable Mini-Lab: StoreItem
*
* StoreItem objects implement the Comparable interface.
*
* @author Alyce Brady
* @version 11 February 2016
*/
public class StoreItem
{
// State: class variables (shared by all instances of the class)
private static int nextAvailableID = 100;
// State: instance variables (each instance has their own copy
private int id;
private String name;
private String category;
private double price;
// Constructors
/**
* Constructs an incomplete object of this class for searching purposes.
* @param name object's name
*/
public StoreItem(String name)
{
// Initialize using more detailed constructor.
this(name, "unknown category", 0.0);
}
/**
* Constructs a new object of this class.
* @param name object's name
* @param category object's category
*/
public StoreItem(String name, String category, double price)
{
// initialise instance variables
this.id = this.nextAvailableID; // set ID from next available ID
this.name = name; // set inst. vars from parameters
this.category = category;
this.price = price;
this.nextAvailableID++; // increment next available ID
}
// Methods
// CODE MISSING: Accessor and toString methods MISSING
// /**
// * Compares this string to the specified object.
// *
// * @param anObject object to be compared
// * @return true if objects are equivalent,
// * false otherwise
// */
// public boolean equals(Object anObject)
// {
// if ( ! (anObject instanceof StoreItem) )
// return false;
//
// StoreItem other = (StoreItem) anObject;
// return this.name.equals(other.getName());
// }
// CODE MISSING: compareTo method MISSING
}