exchange method

Money exchange(
  1. Money amount
)

Buys or sells currencyA

If none of above, Exception is thrown

Implementation

Money exchange(
  /// Amount to exchange
  Money amount,
) {
  if (amount.currency == currencyA) {
    return Money(_round(amount.amount * rateSell), currencyB);
  }

  if (amount.currency == currencyB) {
    return Money(_round(amount.amount / rateBuy), currencyA);
  }

  throw Exception('This currency is not supported by this constructor');
}