#39 Reviewing and Fixing a Customer
Find the errors in the code:
class Pokupatel {
public double money;
SomeCurrencyExchangeService service;
public Pokupatel(float money) {
this.money = money;
this.service = new SomeCurrencyExchangeService();
}
public void setPurchases(double money) {
this.money = 0;
this.money = money;
}
public void addSomeCoins(double coins) {
this.money += coins;
}
public boolean equals(final Object o) {
if (this == o) {
return true;
}
Pokupatel other = (Pokupatel) o;
return other.money == money;
}
Double transferToTheCurrency(String currency) {
try {
return service.transferToTheCurrency(CurrencyEnum.valueOf(currency));
} catch (Throwable e) {
return (double) 0;
}
}
}
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor