PDA

Click to See Complete Forum and Search --> : currency type?


quipy
May 28th, 2003, 02:59 AM
anyone know how to declare a new type? i need a class that handles terms of currency. i.e.

double x = 95.99;
price = new Currency(x);

how can that be done? is it possible? if it is, can other classes in the same folder use the class directly? i.e.

otherPrice = new Currency(y);
product = new product(ID, y);

and the constructor of product in the product class would be:

public product(int ID, Currency y) { }

CornedBee
May 28th, 2003, 04:06 AM
public class Currency
{
// ...
}



That's about the first thing one learns in Java :confused:


But I don't think this even deserves its own class, use java.math.BigDecimal (or simply double) for the value and java.util.Currency for the symbol.