Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class TransactionServiceImpl implements TransactionService, Refreshable {

public static final long MINUTE_IN_MILL_SECONDS = 60000;

private static LinkedList<Transaction> transactionsOfLastMinute = new LinkedList<>();
private static LinkedList<Transaction> transactionsOfLastMinute = new LinkedList<Transaction>();
private static Statistics statistics = new Statistics();

/**
Expand All @@ -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);
}
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down