Skip to content

Commit

Permalink
[#3] Refactor, Use Intellij built-in 'Encapsulate field' suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanLin-TWer committed Jan 14, 2017
1 parent a42819f commit 0204397
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public Money times(int multiplier) {
return new Money(this.amount * multiplier, currency);
}


@Override
public Expression plus(Money addend) {
return new Sum(this, addend);
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/thoughtworks/linesh/multicurrencymoney/Sum.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.thoughtworks.linesh.multicurrencymoney;

public class Sum implements Expression {
public Money augend;
public Money addend;
private Money augend;
private Money addend;

public Sum(Money augend, Money addend) {
this.augend = augend;
Expand All @@ -13,4 +13,12 @@ public Sum(Money augend, Money addend) {
public Expression plus(Money money) {
return null;
}

public Money getAugend() {
return augend;
}

public Money getAddend() {
return addend;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ void should_test_our_assumptions_here() {
Expression result = fiftyDollars.plus(fiftyDollars);
Sum sum = (Sum) result;

assertEquals(fiftyDollars, sum.augend);
assertEquals(fiftyDollars, sum.addend);
assertEquals(fiftyDollars, sum.getAugend());
assertEquals(fiftyDollars, sum.getAddend());
}
}
}

0 comments on commit 0204397

Please sign in to comment.