Class Item

java.lang.Object
  extended by Item

public class Item
extends Object

Represents a grocery item: stores item name, unit name, buying price, selling price, and stock

Version:
1.1
Author:
JP Vergara

Constructor Summary
Item(String aName, String aUnitName, double bPrice, double sPrice)
          Constructor for Item objects.
 
Method Summary
 void addStock(int qty)
          Increases stock for this item.
 double getBuyPrice()
          Returns the buying price of the item
 int getCurrentStock()
          Returns the current stock the item
 String getName()
          Returns the name of the item
 double getSellPrice()
          Returns the selling price of the item
 String getUnitName()
          Returns unit name for the item
 void subtractStock(int qty)
          Decreases stock for this item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Item

public Item(String aName,
            String aUnitName,
            double bPrice,
            double sPrice)
Constructor for Item objects. Set current stock level to 0

Parameters:
aName - name of the item (e.g., "Coke" )
aUnitName - name of unit for the item (e.g., "cans")
bPrice - buying price
sPrice - selling price
Method Detail

addStock

public void addStock(int qty)
Increases stock for this item.

Parameters:
qty - increase stock by qty

getBuyPrice

public double getBuyPrice()
Returns the buying price of the item

Returns:
buying price

getCurrentStock

public int getCurrentStock()
Returns the current stock the item

Returns:
current stock

getName

public String getName()
Returns the name of the item

Returns:
item name

getSellPrice

public double getSellPrice()
Returns the selling price of the item

Returns:
selling price

getUnitName

public String getUnitName()
Returns unit name for the item

Returns:
unit name

subtractStock

public void subtractStock(int qty)
Decreases stock for this item. If the quantity is greater than the currentStock, do nothing

Parameters:
qty - decrease stock by qty