package ru.matevosyan;

import java.util.*;

/**
 * Created by Пользователь on 27.04.2017.
 */
public class Bank {
    private Map<User, List<Account>> accountHolder = new HashMap<>();

    public void addUser(User user) {
        this.accountHolder.put(user, new ArrayList<Account>());
    }

    public void deleteUser(User user) {
        this.accountHolder.remove(user);
    }

    public void addAccountToUser(User user, Account account) {
        this.accountHolder.get(user).add(account);
    }

    public void deleteAccountFromUser(User user, Account account) {
        this.accountHolder.get(user).remove(account);
    }

    public List<Account> getUserAccounts (User user) {
//        Iterator<Map.Entry<User, List<Account>>> accountHolderIterator = accountHolder.entrySet().iterator();
        return  this.accountHolder.get(user);
    }

    public boolean transferMoney (User srcUser, Account srcAccount, User dstUser, Account dstAccount, double amount){

        return false;
    }

}

@@ -108,16 +108,17 @@
  Bank %7B%0A
+%0A
     priv
@@ -268,23 +268,16 @@
 rayList%3C
-Account
 %3E());%0A  
@@ -955,16 +955,17 @@
  amount)
+ 
 %7B%0A%0A     
@@ -971,22 +971,598 @@
     
-return false;%0A
+boolean isisTransfer = true;%0A%0A            if ((this.accountHolder.containsKey(dstUser) && getUserAccounts(dstUser).contains(dstAccount)) &&%0A                    (this.accountHolder.containsKey(srcUser) && getUserAccounts(srcUser).contains(srcAccount))) %7B%0A%0A                if (srcAccount.getValue() %3E amount) %7B%0A%0A                    srcAccount.setValue(srcAccount.getValue() - amount);%0A                    dstAccount.setValue(dstAccount.getValue() + amount);%0A%0A                %7D else %7B%0A                    isisTransfer = false;%0A                %7D%0A%0A            %7D%0A        return isisTransfer;%0A    
     
@@ -1566,8 +1566,9 @@
    %7D%0A%0A%7D%0A
+%0A

complete transferMoney method