Chapter 5. Franc-ly Speaking

$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 CHF

How are we going to approach the first test, the most interesting test, on that list? It still seems to be a big leap. I'm not sure I can write a test that I can implement in one little step. A prerequisite seems to be having an object like Dollar, but to represent francs. If we can get the object Franc to work the way that the object Dollar works now, we'll be closer to being able to write and run the mixed addition test.

We can copy and edit the Dollar test:

public void testFrancMultiplication() {
					Franc five= new Franc(5);
					assertEquals(new Franc(10), ...

Get Test Driven Development: By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.