#304 Code Review of a Client Account Class

Companies:
Sberbank
Themes:
JavaOOPCode Review

Perform a code review:

public class SchetClienta {
    public LinkedList<Double> history;

    SomeCurrencyExchangeService service;

    public SchetClienta(LinkedList<Double> initial) {
        this.history = initial;
        this.service = new SomeCurrencyExchangeService();
    }

    public void setPurchases(Double money) {
        history.add(money);
     }

    public boolean equals(Object o) {
        if (this == o) {
           return true;
        }
        SchetClienta other = (SchetClienta) o;
        return history == other.history;
    }

    Double transferToTheCurrency(String currency) {
        AtomicReference<Double> sum = new AtomicReference<>(0.0);
        try {
            history.forEach(it -> {
                Double converted = service.getValueForCurrency(CurrencyEnum.valueOf(currency), it);
                sum.accumulateAndGet(converted, Double::sum);
            });

            return sum.get();
        } catch (Throwable t) {
            return 0.0;
        }
    }
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in