From 298c353b5a9cec11016cb09937d4fece580c202d Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 4 Dec 2016 18:31:12 +0100 Subject: [PATCH] It is only left a test for addWithdrawal --- .../java/org/craftedsw/feature/Transaction.java | 33 +++++++++++++++++++++- .../craftedsw/feature/TransactionRepository.java | 3 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Transaction.java b/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Transaction.java index 2786699..8ae726c 100644 --- a/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Transaction.java +++ b/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Transaction.java @@ -2,8 +2,39 @@ package org.craftedsw.feature; public class Transaction { + private final String date; + private final int amount; + public Transaction(String date, int amount) { - throw new UnsupportedOperationException(); + this.date = date; + this.amount = amount; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + amount; + result = prime * result + ((date == null) ? 0 : date.hashCode()); + return result; } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Transaction other = (Transaction) obj; + if (amount != other.amount) + return false; + if (date == null) { + if (other.date != null) + return false; + } else if (!date.equals(other.date)) + return false; + return true; + } } diff --git a/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/TransactionRepository.java b/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/TransactionRepository.java index 4c5d20a..d1d07bc 100644 --- a/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/TransactionRepository.java +++ b/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/TransactionRepository.java @@ -1,6 +1,7 @@ package org.craftedsw.feature; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class TransactionRepository { @@ -22,7 +23,7 @@ public class TransactionRepository { } public List allTransactions() { - throw new UnsupportedOperationException(); + return Collections.unmodifiableList(transactions); } } -- 2.1.4