Skip to content

Commit

Permalink
springframeworkguru#23 - TDD Chapter 7 - Apples and Oranges, Compare …
Browse files Browse the repository at this point in the history
…Dollars to Francs - Check class
  • Loading branch information
patrickcorbett committed Apr 22, 2024
1 parent 83d186c commit 584a66e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/guru/springframework/Money.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class Money {
protected int amount;

public boolean equals(Object object) {
// Manual equals, left like this as equals with null or other class will be done later
// Manual equals, left like this as equals with null will be done later
Money money = (Money) object;
return amount == money.amount;
return amount == money.amount && getClass().equals(object.getClass());
}
}
2 changes: 2 additions & 0 deletions src/test/java/guru/springframework/MoneyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ void testMultiplication() {
assertEquals(new Dollar(10), product);
product = five.times(3);
assertEquals(new Dollar(15), product);
// Dollars dont equal francs!
assertNotEquals(new Dollar(5), new Franc(5));
}

@Test
Expand Down

0 comments on commit 584a66e

Please sign in to comment.