Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1. package org.mirapolis.file;
  2.  
  3. import org.jetbrains.annotations.NotNull;
  4.  
  5. import java.util.Collections;
  6. import java.util.List;
  7. import java.util.Map;
  8.  
  9. public class Main {
  10.  
  11.     enum Type {
  12.         DEPOSIT, WITHDRAWAL
  13.     }
  14.  
  15.     static class Transaction {
  16.         final Type type;
  17.         final String currency;
  18.         final Long amount;
  19.  
  20.         Transaction(@NotNull Type type, @NotNull String currency, @NotNull Long amount) {
  21.             this.type = type;
  22.             this.currency = currency;
  23.             this.amount = amount;
  24.         }
  25.  
  26.         @NotNull
  27.         String getCurrency() {
  28.             return currency;
  29.         }
  30.  
  31.         @NotNull
  32.         Long getAmount() {
  33.             return amount;
  34.         }
  35.  
  36.         @NotNull
  37.         Type getType() {
  38.             return type;
  39.         }
  40.     }
  41.     /**
  42.      * Реализуйте метод, подсчитывающий среднее значение депозитов среди переданных транзакций,
  43.      * группирующий их по значению валюты
  44.      *
  45.      * @param transactions список транзакций
  46.      * @return мапа, в которой ключи - валюты (хранятся в алфавитном порядке), значения - среднее значение всех
  47.      * транзакций типа "депозит" в данной валюте
  48.      */
  49.     public static Map<String, Double> getAverageDepositAmountByCurrency(List<Transaction> transactions) {
  50.         //TODO
  51.         return Collections.emptyMap();
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement