Skip to content

Commit dc14003

Browse files
committed
Initial Test for Multi Currency Money [springframeworkguru#17-springframeworkguru#18. Degenerate Objects]
1 parent 50b78d9 commit dc14003

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package guru.springframework;
2+
3+
public class Dollar {
4+
int amount;
5+
public Dollar(int amount) {
6+
this.amount = amount;
7+
}
8+
9+
Dollar times(int multiplier) {
10+
return new Dollar(this.amount * multiplier);
11+
}
12+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package guru.springframework;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
7+
public class MoneyTest {
8+
@Test
9+
void testMultiplication() {
10+
Dollar five = new Dollar(5);
11+
Dollar product = five.times(2);
12+
assertEquals(10, product.amount);
13+
product =five.times(3);
14+
assertEquals(15, product.amount);
15+
}
16+
17+
}

0 commit comments

Comments
 (0)