Skip to content

Commit 19ad9c6

Browse files
patrick.corbett@infomotion.depatrickcorbett
authored andcommitted
springframeworkguru#20 - Privacy - field was make private and the checking of equality now works using the dollar object instead of teh value of the amount field
(cherry picked from commit ff6e64a)
1 parent f8c02f5 commit 19ad9c6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/guru/springframework/Dollar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
public class Dollar {
77

8-
int amount;
8+
private int amount;
99

1010
public Dollar(int pAmount) {
1111
amount = pAmount;

src/test/java/guru/springframework/MoneyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class MoneyTest {
1212
void testMultiplication() {
1313
Dollar five = new Dollar(5);
1414
Dollar product = five.times(2);
15-
Assertions.assertEquals(10, product.amount);
15+
Assertions.assertEquals(new Dollar(10), product);
1616
product = five.times(3);
17-
Assertions.assertEquals(15, product.amount);
17+
Assertions.assertEquals(new Dollar(15), product);
1818
}
1919

2020
@Test

0 commit comments

Comments
 (0)