diff --git a/src/main/java/com/banking/banking/statistics/TransactionServiceImpl.java b/src/main/java/com/banking/banking/statistics/TransactionServiceImpl.java index cdf4f84..efe027b 100644 --- a/src/main/java/com/banking/banking/statistics/TransactionServiceImpl.java +++ b/src/main/java/com/banking/banking/statistics/TransactionServiceImpl.java @@ -16,7 +16,7 @@ public class TransactionServiceImpl implements TransactionService, Refreshable { public static final long MINUTE_IN_MILL_SECONDS = 60000; - private static LinkedList transactionsOfLastMinute = new LinkedList<>(); + private static LinkedList transactionsOfLastMinute = new LinkedList(); private static Statistics statistics = new Statistics(); /** @@ -42,6 +42,7 @@ public boolean registerTransaction(Transaction transaction) { * * @return statistics */ + // why do you create anew obect ?? just return the statistics object .. public Statistics getStatistics() { return new Statistics(statistics); } @@ -142,6 +143,8 @@ private void addAmount(double amount) { * @return double: the amount from the highest transaction */ private double getAmountOfMaxTransaction() { + // this is not good, youhave already the statistic calculated why do you have to loop over the list again ??? + //return statistics.getMax(); double maxAmount = 0; for (Transaction transaction : transactionsOfLastMinute) { double amount = transaction.getAmount(); @@ -157,6 +160,8 @@ private double getAmountOfMaxTransaction() { * @return double: minimum amount of transaction from transactions */ private double getAmountOfMinTransaction() { + // this is not good, youhave already the statistic calculated why do you have to loop over the list again ??? + //return statistics.getMin(); double minAmount = Double.POSITIVE_INFINITY; for (Transaction transaction : transactionsOfLastMinute) { double amount = transaction.getAmount();