Permalink
Browse files

Inner loop - Green: Implement statement lines generation

  • Loading branch information...
CarlosMChica committed May 2, 2016
1 parent e53c6ba commit 67631395b147b31bd1887fdad8485a298e6eff12
Showing with 17 additions and 6 deletions.
  1. +17 −6 app/src/main/java/me/panavtec/androidbankkata/account/statement/Statement.java
@@ -1,13 +1,28 @@
package me.panavtec.androidbankkata.account.statement;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import me.panavtec.androidbankkata.account.transaction.Transaction;
import static java.util.Collections.unmodifiableList;
public class Statement {
private List<Transaction> transactions;
private final List<Transaction> transactions;
public Statement(List<Transaction> transactions) {
this.transactions = transactions;
this.transactions = unmodifiableList(transactions);
}
public List<StatementLine> lines() {
AtomicInteger currentBalance = new AtomicInteger(0);
ArrayList<StatementLine> lines = new ArrayList<>();
for (Transaction transaction : transactions) {
lines.add(new StatementLine(transaction, currentBalance.addAndGet(transaction.getAmount())));
}
return lines;
}
@Override public String toString() {
@@ -34,8 +49,4 @@ public Statement(List<Transaction> transactions) {
@Override public int hashCode() {
return transactions != null ? transactions.hashCode() : 0;
}
public List<StatementLine> lines() {
return null;
}
}

0 comments on commit 6763139

Please sign in to comment.