## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

## Chapter 8. Makin' Objects

 \$5 + 10 CHF = \$10 if rate is 2:1\$5 * 2 = \$10Make “amount” privateDollar side effects?Money rounding?equals()hashCode()Equal nullEqual object5 CHF * 2 = 10 CHFDollar/Franc duplicationCommon equalsCommon timesCompare Francs to DollarsCurrency?

The two implementations of times() are remarkably similar:

##### Franc
 ``` Franc times(int multiplier) { return new Franc(amount * multiplier); } ```
##### Dollar
 ``` Dollar times(int multiplier) { return new Dollar(amount * multiplier); } ```

We can take a step toward reconciling them by making them both return a Money:

##### Franc
 ``` Money times(int multiplier) { return new Franc(amount * multiplier); } ```
##### Dollar
 ``` Money times(int multiplier) { return new Dollar(amount * multiplier); ...```

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required