package ru.job4j;

/**
 * Created by ANTON on 31.05.2017.
 */
public class BankReception {
}

@@ -16,78 +16,2473 @@
 j;%0A%0A
-/**%0A * Created by ANTON on 31.05.2017.%0A */%0Apublic class BankReception %7B
+import java.util.*;%0A/**%0A * Testing Task 3.4.2%0A * Create collection Map for bank%0A *%0A * @author Anton Vasilyuk%0A * @version 1.0%0A * @since 0.1%0A */%0Apublic class BankReception %7B%0A%0A    /**%0A     * .%0A     * datebase bank%0A     */%0A    private Map%3CUser, List%3CAccount%3E%3E bank = new LinkedHashMap%3C%3E();%0A%0A    /**%0A     * .%0A     * Add user to datebase%0A     *%0A     * @param user%0A     */%0A    public void addUser(User user) %7B%0A        List%3CAccount%3E account = new ArrayList%3C%3E();%0A        this.bank.put(user, account);%0A    %7D%0A%0A    /**%0A     * .%0A     * Remove user from datebase%0A     *%0A     * @param user%0A     */%0A    public void deleteUser(User user) %7B%0A        this.bank.remove(user);%0A    %7D%0A%0A    /**%0A     * .%0A     * Add account to bank account user%0A     *%0A     * @param user%0A     * @param account%0A     */%0A    public void addAccountToUser(User user, Account account) %7B%0A        List%3CAccount%3E list = this.bank.get(user);%0A        list.add(account);%0A        this.bank.put(user, list);%0A    %7D%0A%0A    /**%0A     * .%0A     * Delete account from bank account user%0A     *%0A     * @param user%0A     * @param account%0A     */%0A    public void deleteAccountFromUser(User user, Account account) %7B%0A        List%3CAccount%3E list = this.bank.get(user);%0A        int position = list.indexOf(account);%0A        list.remove(position);%0A        this.bank.put(user, list);%0A    %7D%0A%0A    /**.%0A     * Getter for user account%0A     * @param user%0A     * @return%0A     */%0A    public List%3CAccount%3E getUserAccounts(User user) %7B%0A        return this.bank.get(user);%0A    %7D%0A%0A    public boolean transferMoney (User srcUser, Account srcAccount, User dstUser, Account dstAccount, double amount) %7B%0A%0A        List%3CAccount%3E listOne = this.bank.get(srcUser);%0A        List%3CAccount%3E listSecond = this.bank.get(dstUser);%0A%0A        Account accountOne = listOne.get(listOne.indexOf(srcAccount));%0A        Account accountSecond = listSecond.get(listSecond.indexOf(dstAccount));%0A%0A        double valueOne = accountOne.getValue();%0A        double valueTwo = accountSecond.getValue();%0A%0A        if ((valueOne - amount) %3C 0) %7Breturn false;%7D%0A        accountSecond.setValue(valueTwo + amount);%0A        listSecond.set(listSecond.indexOf(dstAccount), accountSecond);%0A        this.bank.put(dstUser, listSecond);%0A        accountOne.setValue(valueOne - amount);%0A        listOne.set(listOne.indexOf(srcAccount), accountOne);%0A        this.bank.put(srcUser, listOne);%0A%0A        return true;%0A     %7D%0A%0A     public Map%3CUser, List%3CAccount%3E%3E getBankBase() %7B%0A        return this.bank;%0A     %7D
 %0A%7D%0A

add file for chapter_003_3.4.2