Money.fromDollars constructor

Money.fromDollars(
  1. int dollars,
  2. int cents
)

Implementation

factory Money.fromDollars(int dollars, int cents)
{
  if (cents > MAX_CENTS) {
    throw new IllegalArgumentException("Cents value greater than MAX_CENTS.");
  }

  return new Money(dollars * 100 + cents);
}