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;
+ }
}
package org.craftedsw.feature;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
public class TransactionRepository {
}
public List<Transaction> allTransactions() {
- throw new UnsupportedOperationException();
+ return Collections.unmodifiableList(transactions);
}
}