SOURCECODE |
How to... incorporate a Currency
Description:
A Currency is a special Catalog. Itīs CatalogItems are CurrencyItems which represent the different denominations of the Currency.
(See also: HowTo..incorporate a Catalog and HowTo..incorporate a MoneyBag on a Currency )
The use of CurrencyImpl, the implementation of the interface Currency is recommended.
ToDo's:
- Eventually define a new Currency (See also: HowTo..define a new Currency )
- Make a new instance of CurrencyImpl ( ex.:
CurrencyImpl c = new CurrencyImpl(String sName)
).
- Add the Currency to the Shopīs global list of catalogs (
Shop.getTheShop().addCatalog(Catalog c)
).
Uses:
Currency CurrencyItem CurrencyImpl CurrencyItemImpl
// mainly imports
import data.ooimpl.CurrencyImpl;
// Main Class
public class MyShop extends Shop
{
// Constructor
public MyShop()
{
super();
}
// Main Method
public static void main (String[] noArgs)
{
// the singleton instance of the shop
MyShop myshop = new MyShop();
2
// a new currency
CurrencyImpl usCatalog = new CurrencyUS("US_Catalog");
3
// adding the currency to the shop
myshop.addCatalog(usCatalog);
}
}