Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.mirapolis.file;
- import org.jetbrains.annotations.NotNull;
- import java.util.Collections;
- import java.util.List;
- import java.util.Map;
- public class Main {
- enum Type {
- DEPOSIT, WITHDRAWAL
- }
- static class Transaction {
- final Type type;
- final String currency;
- final Long amount;
- Transaction(@NotNull Type type, @NotNull String currency, @NotNull Long amount) {
- this.type = type;
- this.currency = currency;
- this.amount = amount;
- }
- @NotNull
- String getCurrency() {
- return currency;
- }
- @NotNull
- Long getAmount() {
- return amount;
- }
- @NotNull
- Type getType() {
- return type;
- }
- }
- /**
- * Реализуйте метод, подсчитывающий среднее значение депозитов среди переданных транзакций,
- * группирующий их по значению валюты
- *
- * @param transactions список транзакций
- * @return мапа, в которой ключи - валюты (хранятся в алфавитном порядке), значения - среднее значение всех
- * транзакций типа "депозит" в данной валюте
- */
- public static Map<String, Double> getAverageDepositAmountByCurrency(List<Transaction> transactions) {
- //TODO
- return Collections.emptyMap();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement