File tree Expand file tree Collapse file tree
src/test/java/guru/springframework Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package guru .springframework ;
2+
3+ public class Franc {
4+ private int amount ;
5+ public Franc (int amount ) {
6+ this .amount = amount ;
7+ }
8+
9+ Franc times (int multiplier ) {
10+ return new Franc (this .amount * multiplier );
11+ }
12+
13+ @ Override
14+ public boolean equals (Object o ) {
15+ Franc franc = (Franc ) o ;
16+ return amount == franc .amount ;
17+ }
18+
19+ }
Original file line number Diff line number Diff line change 77
88public class MoneyTest {
99 @ Test
10- void testMultiplication () {
10+ void testMultiplicationDollar () {
1111 Dollar five = new Dollar (5 );
1212 Dollar product = five .times (2 );
1313 assertEquals (new Dollar (10 ), product );
@@ -16,8 +16,23 @@ void testMultiplication() {
1616 }
1717
1818 @ Test
19- void testEquality () {
19+ void testEqualityDollar () {
2020 assertEquals (new Dollar (6 ), new Dollar (6 ));
2121 assertNotEquals (new Dollar (6 ), new Dollar (8 ));
2222 }
23+
24+ @ Test
25+ void testMultiplicationFranc () {
26+ Franc five = new Franc (5 );
27+ Franc product = five .times (2 );
28+ assertEquals (new Franc (10 ), product );
29+ product = five .times (3 );
30+ assertEquals (new Franc (15 ), product );
31+ }
32+
33+ @ Test
34+ void testEqualityFranc () {
35+ assertEquals (new Franc (6 ), new Franc (6 ));
36+ assertNotEquals (new Franc (6 ), new Franc (8 ));
37+ }
2338}
You can’t perform that action at this time.
0 commit comments