Results 1 to 2 of 2

Thread: currency type?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    103

    currency type?

    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) { }
    Last edited by quipy; May 28th, 2003 at 03:19 AM.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Code:
    public class Currency
    {
      // ...
    }

    That's about the first thing one learns in Java


    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.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width