SOURCECODE |
How to... define a StockItem
Description:
StockItems are Stocks(SubStocks) or items itself. If they to be used in a CountingStock, they´ll be the representation of a certain amount of items of a special category. If they are to be used in a StoringStock, they´ll represent an individual item of a special category.
(See also: HowTo incorporate a CountingStock on a Catalog, HowTo incorporate a StoringStock on a Catalog )
It is often usefull to make a subclass of StockItemImpl, but implementing the interface StockItem may also be necessary.
If you wanted to use a CountingStock, you may make an instance of StockItemImpl itself.
ToDo's:
- Incorporate a subclass of StockItemImpl.
- Add needed attributes to characterize this item.
- Add constructors to set the items name and other attributes.
(Every constructor must invoke super(name), therefore a StockItem has to have a name)
- Add other needed methods.
Uses:
StockItem StockItemImpl
// mainly imports
import data.ooimpl.StockItemImpl;
import users.User;
1
// Main Class
public class MyStockItem extends StockItemImpl
{
2
// Attibutes
User owner;
3
// Constructor
public MyStockItem(String name)
{
super(name);
}
4
/////////////////////////////
// getter and setter methods
public void setOwner(String name)
{
owner = new User(name);
}
public User getOwner()
{
return owner;
}
}