Großmarkt

market.statistics
Class CSalesStats

java.lang.Object
  |
  +--data.AbstractNameable
        |
        +--data.ooimpl.CatalogItemImpl
              |
              +--data.ooimpl.CatalogImpl
                    |
                    +--market.statistics.CSalesStats
All Implemented Interfaces:
Catalog, CatalogItem, Cloneable, Comparable, DataBasketEntryDestination, DataBasketEntrySource, DataBasketKeys, ListenableCatalog, Nameable, NameContext, SelfManagingDBEDestination, SelfManagingDBESource, Serializable

public class CSalesStats
extends CatalogImpl

Represents a statistics of one month. It contains the statistics of every single offered article and more general information such as paid wages and miscellaneous costs. This class is also used as container in which overall statistics of a given range of time are brought together. The items of this catalog are CISalesStats.

See Also:
Statistics.getOverallStats(int, int, int, int), Serialized Form

Field Summary
 
Fields inherited from class data.ooimpl.CatalogImpl
m_lhListeners, m_nModCount
 
Fields inherited from class data.AbstractNameable
m_ncContext, m_pcsPropertyListeners
 
Fields inherited from interface data.CatalogItem
VALUE_PROPERTY
 
Fields inherited from interface data.Nameable
NAME_PROPERTY
 
Fields inherited from interface data.DataBasketKeys
CATALOG_ITEM_MAIN_KEY, STOCK_ITEM_MAIN_KEY
 
Constructor Summary
CSalesStats(int year, int month)
          Creates a new statistics container.
 
Method Summary
 void addOrders(CSalesStats csToAdd)
          Adds the all order histories which are stored in a different CSalesStats to this one.
 void addRevenue(int revenue)
          Adds the value customer's purchase to this month's revenue.
 void addSales(UCustomer customer, double discount)
          Adds a customer's purchase to the article statistics.
 CISalesStats get(String key)
           
 int getCosts()
           
 int getMonth()
           
 int getOrderCosts()
           
 int getRevenue()
           
 int getWages()
           
 int getYear()
           
 void initPriceHistory()
          Initializes the price history of each article with the current article's bid.
 void setCosts(int costs)
          Sets the miscellaneous costs of the market.
 void setWages(int wages)
          Saves the sum of the employee's wages.
 String toString()
           
 void updateOrderHistory(CountingStock cs)
          Adds the current date to the order history of an article's statistics, whenever the manager purchases it.
 
Methods inherited from class data.ooimpl.CatalogImpl
add, addCatalogChangeListener, checkNameChange, commitAdd, commitRemove, contains, createPeer, fireCanEditCatalogItem, fireCanRemoveCatalogItem, fireCatalogItemAddCommit, fireCatalogItemAdded, fireCatalogItemAddRollback, fireCatalogItemRemoveCommit, fireCatalogItemRemoved, fireCatalogItemRemoveRollback, fireCommitEditCatalogItem, fireEditingCatalogItem, fireRollbackEditCatalogItem, get, getEditableCopy, getEditingItemsContainer, getItemsContainer, getItemsLock, getNCMonitor, getShallowClone, getTemporaryAddedItemsContainer, getTemporaryRemovedItemsContainer, iterator, keySet, nameHasChanged, remove, remove, removeCatalogChangeListener, rollbackAdd, rollbackRemove, size
 
Methods inherited from class data.ooimpl.CatalogItemImpl
addValueListener, compareTo, equals, getCatalog, getValue, isEditable, removeValueListener, setValue
 
Methods inherited from class data.AbstractNameable
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface data.CatalogItem
addValueListener, getCatalog, getValue, removeValueListener
 
Methods inherited from interface data.Nameable
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

CSalesStats

public CSalesStats(int year,
                   int month)
Creates a new statistics container. To month that those statistics have been recorded is passed via the parameters.

Parameters:
year - the year in which the statistics were recorded.
month - the month in which the statistics were recorded.
Method Detail

getYear

public int getYear()
Returns:
the statistic's year

getMonth

public int getMonth()
Returns:
the statistic's month

initPriceHistory

public void initPriceHistory()
Initializes the price history of each article with the current article's bid. This initial bid is used for calculating average prices over a range of time. Without it, it would be possible to have an empty price history for the chosen range of time which makes calculations on this history more difficult.
This method is called only on creation of a CCustomerStats, but it cannot be put into the constructor, because there are cases when the initialization is not desired.

See Also:
Statistics.getArticleStats(String, int, int, int, int), Statistics.getOverallStats(int, int, int, int), SMarket#c_dailyStats

get

public CISalesStats get(String key)
Parameters:
key - the key of the CISalesStats to be returned.
Returns:
the CISalesStats with the according key.

addSales

public void addSales(UCustomer customer,
                     double discount)
Adds a customer's purchase to the article statistics.

Parameters:
customer - the customer whose purchase is to be added.
discount - the discount allowed by the market.

updateOrderHistory

public void updateOrderHistory(CountingStock cs)
Adds the current date to the order history of an article's statistics, whenever the manager purchases it.

Parameters:
cs - the manager's purchase.
See Also:
CISalesStats.ordered(java.util.Calendar, int)

addRevenue

public void addRevenue(int revenue)
Adds the value customer's purchase to this month's revenue.

Parameters:
revenue - the revenue to be added.

getRevenue

public int getRevenue()
Returns:
this month's revenue.

setCosts

public void setCosts(int costs)
Sets the miscellaneous costs of the market. Only used while instance of this class represents the current month.

Parameters:
costs - the costs to be set.

getCosts

public int getCosts()
Returns:
this month's miscellaneous costs.

getOrderCosts

public int getOrderCosts()
Returns:
the costs of all article purchases the manager has made this month.

setWages

public void setWages(int wages)
Saves the sum of the employee's wages. Only used when month ends and statistics are saved to CCompleteStats

Parameters:
wages - the wages to be set.

getWages

public int getWages()
Returns:
the saved wages. Will not work if instance of this class represents current month's statistics.

toString

public String toString()
Overrides:
toString in class CatalogImpl

addOrders

public void addOrders(CSalesStats csToAdd)
Adds the all order histories which are stored in a different CSalesStats to this one.
Using this method multiple times creates a complete order history for any desired range of time. With the help of getOrderCosts() it is now possible to easily compute the total of money spent on purchases during that time.

Parameters:
csToAdd - the CSalesStats, which contains the order histories to be added.
See Also:
Statistics.getOverallStats(int, int, int, int)

Großmarkt