retail
Class Product

java.lang.Object
  extended by retail.Product
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
CD, DVD

public class Product
extends java.lang.Object
implements java.lang.Comparable


Field Summary
protected  int currInventory
          current inventory
protected  java.lang.String name
          name of the product
protected  id.ID sku
          uniquely identifies a given product
protected  int totalSold
          number sold
 
Constructor Summary
Product()
          Creates a new default instance of Product
Product(int skuLen, java.lang.String nam, double price, double cost, int inv, int sold)
          constructor with all info but ID supplied (id will be generated as a random code length passed).
Product(java.util.Scanner scan)
          Creates a new instance of Product given a properly positioned scanner - pointing to the appropriate place in a comma delimited string containing the name, cost, price, inventory and number sold (such as might be obtained via reading in a file that has one line per Product) Assumes info is organized in that order.
Product(java.lang.String allInfo)
          Creates a new instance of Product given a comma delimited string containing the name, cost, price, inventory and number sold (such as might be obtained via reading in a file that has one line per Song) Assumes info is organized in that order.
Product(java.lang.String nam, double price, double cost, int inv, int sold)
          constructor with all info but ID supplied (id will be generated as a random 6 long code).
Product(java.lang.String id, java.lang.String nam, double price, double cost, int inv)
          constructor with all info except number sold supplied (id as a String).
Product(java.lang.String id, java.lang.String nam, double price, double cost, int inv, int sold)
          constructor with all info supplied (id as a String).
 
Method Summary
 boolean addInventory(int number)
          we buy more inventory
 boolean buy(int number)
          somebody buys from us
 int compareTo(java.lang.Object obj)
          Compares two Products - needed for sorting - required since implements Comparable interface returns negative if object comparing to is less, zero if object comparing to is equal, positive if object comparing to is greater.
 boolean equals(java.lang.Object toCompare)
          report whether passed object is completely equal in contents to invoking object
 double getCostOfGoodsSold()
          obtain the cost of goods sold (for accountants)
 double getCostOfGoodsSoldOld()
          don't use
 double getCostOfGoodsStocked()
          obtain the cost of all goods stocked (sold and unsold)
 double getCostOfGoodsStockedOld()
          don't use
 int getCurrInventory()
          obtain the current inventory
 java.lang.String getName()
          report product name
 double getProfit()
          obtain the revenues brought in
 double getProfitMargin()
          report our profit margin for any one of these
 double getProfitOld()
          don't use
 double getRetailCost()
          report our customer's cost
 double getRevenues()
          obtain the revenues brought in
 double getRevenuesOld()
          obtain the revenues brought in
 id.ID getSku()
          report SKU
 java.lang.String getSkuString()
          report SKU as String
 int getTotalSold()
          obtain the current number sold
 int getTotalStocked()
          obtain the number stocked (sold or unsold)
 double getValueOfInventory()
          obtain the cost of current inventory
 double getValueOfInventoryOld()
          don't use
 double getWholesaleCost()
          report our cost
 boolean setName(java.lang.String nam)
          change value for name Currently no validation
 boolean setRetailCost(double price)
          change value for customer cost Must be positive and greater than wholesale cost
 boolean setSku(id.ID sk)
          change value for SKU - passed an ID Currently no validation - but I'm sure there should be rules
 boolean setSku(java.lang.String sk)
          change value for SKU - passed a String Currently no validation - but I'm sure there should be rules
 boolean setWholesaleCost(double cost)
          change value for our cost Must be positive
 java.lang.String toString()
          create a string representation for the Product object
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sku

protected id.ID sku
uniquely identifies a given product


name

protected java.lang.String name
name of the product


currInventory

protected int currInventory
current inventory


totalSold

protected int totalSold
number sold

Constructor Detail

Product

public Product()
Creates a new default instance of Product


Product

public Product(java.lang.String nam,
               double price,
               double cost,
               int inv,
               int sold)
constructor with all info but ID supplied (id will be generated as a random 6 long code). Inputs not checked unfortunately.


Product

public Product(int skuLen,
               java.lang.String nam,
               double price,
               double cost,
               int inv,
               int sold)
constructor with all info but ID supplied (id will be generated as a random code length passed). Inputs not checked unfortunately.


Product

public Product(java.lang.String id,
               java.lang.String nam,
               double price,
               double cost,
               int inv,
               int sold)
constructor with all info supplied (id as a String). Inputs not checked unfortunately.


Product

public Product(java.lang.String id,
               java.lang.String nam,
               double price,
               double cost,
               int inv)
constructor with all info except number sold supplied (id as a String). Number sold assumed to be zero. Inputs not checked unfortunately.


Product

public Product(java.lang.String allInfo)
Creates a new instance of Product given a comma delimited string containing the name, cost, price, inventory and number sold (such as might be obtained via reading in a file that has one line per Song) Assumes info is organized in that order. Inputs are checked; default-ish values used instead of bad values.


Product

public Product(java.util.Scanner scan)
Creates a new instance of Product given a properly positioned scanner - pointing to the appropriate place in a comma delimited string containing the name, cost, price, inventory and number sold (such as might be obtained via reading in a file that has one line per Product) Assumes info is organized in that order. Scanner has side effects - it will be updated, moving on to the next item Inputs are checked; default-ish values used instead of bad values.

Method Detail

getSku

public id.ID getSku()
report SKU


getSkuString

public java.lang.String getSkuString()
report SKU as String


getName

public java.lang.String getName()
report product name


getRetailCost

public double getRetailCost()
report our customer's cost


getWholesaleCost

public double getWholesaleCost()
report our cost


getCurrInventory

public int getCurrInventory()
obtain the current inventory


getTotalSold

public int getTotalSold()
obtain the current number sold


getProfitMargin

public double getProfitMargin()
report our profit margin for any one of these


getTotalStocked

public int getTotalStocked()
obtain the number stocked (sold or unsold)


getValueOfInventory

public double getValueOfInventory()
obtain the cost of current inventory


getValueOfInventoryOld

public double getValueOfInventoryOld()
                              throws ProductNotKnownException
don't use

Throws:
ProductNotKnownException

getCostOfGoodsSold

public double getCostOfGoodsSold()
obtain the cost of goods sold (for accountants)


getCostOfGoodsSoldOld

public double getCostOfGoodsSoldOld()
                             throws ProductNotKnownException
don't use

Throws:
ProductNotKnownException

getCostOfGoodsStocked

public double getCostOfGoodsStocked()
obtain the cost of all goods stocked (sold and unsold)


getCostOfGoodsStockedOld

public double getCostOfGoodsStockedOld()
                                throws ProductNotKnownException
don't use

Throws:
ProductNotKnownException

getRevenues

public double getRevenues()
obtain the revenues brought in


getRevenuesOld

public double getRevenuesOld()
                      throws ProductNotKnownException
obtain the revenues brought in

Throws:
ProductNotKnownException

getProfit

public double getProfit()
obtain the revenues brought in


getProfitOld

public double getProfitOld()
                    throws ProductNotKnownException
don't use

Throws:
ProductNotKnownException

setSku

public boolean setSku(id.ID sk)
change value for SKU - passed an ID Currently no validation - but I'm sure there should be rules


setSku

public boolean setSku(java.lang.String sk)
change value for SKU - passed a String Currently no validation - but I'm sure there should be rules


setName

public boolean setName(java.lang.String nam)
change value for name Currently no validation


setRetailCost

public boolean setRetailCost(double price)
change value for customer cost Must be positive and greater than wholesale cost


setWholesaleCost

public boolean setWholesaleCost(double cost)
change value for our cost Must be positive


buy

public boolean buy(int number)
somebody buys from us


addInventory

public boolean addInventory(int number)
we buy more inventory


toString

public java.lang.String toString()
create a string representation for the Product object

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object toCompare)
report whether passed object is completely equal in contents to invoking object

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)
Compares two Products - needed for sorting - required since implements Comparable interface returns negative if object comparing to is less, zero if object comparing to is equal, positive if object comparing to is greater. Compare based on Product's total revenues so far

Specified by:
compareTo in interface java.lang.Comparable