2 package org.apidesign.apifest08.currency;
4 public final class Rate {
8 public Rate(int amountA, int amountB) {
9 rate = amountA / (double)amountB;
11 throw new IllegalArgumentException("Exchange rate must be positive.");
15 public Rate(double amountA, double amountB) {
16 rate = amountA / amountB;
18 throw new IllegalArgumentException("Exchange rate must be positive.");
22 public Rate(double rate) {
25 throw new IllegalArgumentException("Exchange rate must be positive.");
29 public double convertAtoB(int a) {
33 public double convertAtoB(double a) {
37 public double convertBtoA(int b) {
41 public double convertBtoA(double b) {
47 public boolean equals(Object obj) {
51 if (getClass() != obj.getClass()) {
54 final Rate other = (Rate) obj;
59 public int hashCode() {
65 public String toString() {