type.lib
Class Fresh

java.lang.Object
  extended by type.lib.Item
      extended by type.lib.Fresh
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Item>

public class Fresh
extends Item
implements java.io.Serializable

This class encapsulates a fresh item. It differs from an ordinary item in that it has an expiry date.

Version:
7.0 - Summer 2010
Author:
H. Roumani, roumani@cse.yorku.ca
See Also:
Serialized Form

Constructor Summary
Fresh(java.lang.String number, java.lang.String name, double price, java.util.Date expiry)
          Construct a fresh inventory item with the given number, name, selling price per unit, and expiry date, and a zero opening stock quantity.
 
Method Summary
 boolean equals(java.lang.Object other)
          Test the equality of items.
 java.util.Date getExpiry()
          Determine the expiry date of this Item.
 java.lang.String toString()
          Construct a string representation of this item.
 
Methods inherited from class type.lib.Item
compareTo, getName, getNumber, getPurchasedQty, getPurchases, getSales, getSoldQty, getStock, getUnitCost, getUnitPrice, hashCode, purchase, sell, sell, setUnitPrice
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Fresh

public Fresh(java.lang.String number,
             java.lang.String name,
             double price,
             java.util.Date expiry)
Construct a fresh inventory item with the given number, name, selling price per unit, and expiry date, and a zero opening stock quantity.

Parameters:
number - the item number.
name - the name of the item.
price - the selling price per unit of the item.
expiry - the date on which the item will expire.
Throws:
java.lang.RuntimeException - if any of the passed parameters is null.
Method Detail

getExpiry

public java.util.Date getExpiry()
Determine the expiry date of this Item.

Returns:
a copy of the expiry date of this item.

toString

public java.lang.String toString()
Construct a string representation of this item.

Overrides:
toString in class Item
Returns:
the string: "Fresh Item# xxxxxx name", where xxxxxx is the item number and name is its name.

equals

public boolean equals(java.lang.Object other)
Test the equality of items. An object is considered equal to this item if it is a Fresh object with the same number and expiry date as this one.

Overrides:
equals in class Item
Parameters:
other - a reference to the object to test equality with.
Returns:
true if other is not null and it points to an object that is equal (as defined above) to this object. The return is false otherwise.


Java by Abstraction: A Client-View Approach