会員情報と振込先データ
会員情報
名前    残高       ID     パスワード    本店or支店
愛甲    10000    aikou    12365        本店
井田    5000      ida       98745        本店
宇賀    15000    uga      45698        支店

振込先
銀行名        本or支店     預金科目
楽天             支店           普通
住信SBI        本店           普通
住信SBI        支店           普通
 

ポートフォリオの説明
オブジェクト指向でのコードでmainとMainScreen(メインメニュー)とTransferScreen(振込)とBalanceInquiry(残高照会)とCustomer(お客様)クラスとBank(銀行)があります。
main以外のクラスでフィールドをカプセル化していて、クラスMainScreenとCustomerとBankでコンストラクタ呼び出しをしています。
最初にmainでインスタンスの生成をしています。
Customerへ遷移してお客様情報のインスタンスを生成してMapのコネクションに格納して、呼び出しではIDとパスワードの入力をして両方正しければCustomer情報をreturnしてmainのクラスcに代入し他クラスに残高を代入します。
この後のメインメニューでは振込と残高照会があり、振込を選択するとTransferScreenに移動して、振込に必要な情報を入力していただいて最後に確認をします。
結果がNGであれば最初からの入力になり、OKであればmianクラスに戻り他クラスに代入して更新します。
残高照会は、金額の表示のみになります。

 

package 銀行;

public class Main {

    public static void main(String[] args) {
 //各クラスのインスタンスの生成と配列を作成
        MainScreen ms = new MainScreen();
        TransferScreen ts = new TransferScreen();
        BalanceInquiry bi = new BalanceInquiry();
        Customer cus = new Customer();

        Customer c = cus.customerMatch();//ログイン作業を開始
 
//お客様の名前・本支店・残高を同期
        ms.setName(c.getName());
        ms.setBankName(c.getBankName());
        ms.setOfficeName(c.getOfficeName());
        ms.setBlance(c.getBlance());
        ts.setBlance(c.getBlance());
        bi.setBlance(c.getBlance());

//メインメニュー
        for (int k = 1; k < 99; k++) {
            ms.mainMenu();
            int press = new java.util.Scanner(System.in).nextInt();
            if (press == 1) {
                ts.payeeBank();
                ms.setBlance(ts.getBlance());    //振込後の残高の更新
                bi.setBlance(ts.getBlance());
                c.setBlance(ts.getBlance());
            } else if(press == 2) {
                bi.viewBalance();
                break;
            }
        }
    }
}

 

package 銀行;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class MainScreen {
    private String name;
    private int blance;    //残高を宣言
    private String bankName;    //銀行名を宣言
    private String officeName;    //銀行の本支店を宣言
    private String depositAccount;        //預金科目を宣言
    private int accountNumber;        //口座番号を宣言
    private DateTimeFormatter dtf; //日付のパターンを宣言
    private LocalDateTime now; //現在時刻を宣言
    
    public MainScreen() {    //日付のコンストラクタ呼び出し
        dtf = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
     }
//メニュー画面    
    public void mainMenu() {
        now = LocalDateTime.now();
        String s = dtf.format(now);
        System.out.println("          " + s);
        System.out.println("こんにちは" + this.name + "さん");
        System.out.println("残高 " + this.blance + "円");
        System.out.println(this.bankName);
        System.out.println(this.officeName);
        System.out.println("メニューの選択をお願いします");
        System.out.println("1:振込  2:残高照会");
    }
    
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getBlance() {
        return this.blance;
    }

    public void setBlance(int blance) {
        this.blance = blance;
    }

    public String getOfficeName() {
        return this.officeName;
    }

    public void setOfficeName(String officeName) {
        this.officeName = officeName;
    }

    public String getBankName() {
        return this.bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }
}

 

package 銀行;

import java.util.LinkedList;
import java.util.List;

public class TransferScreen {
    private int blance;    //残高を宣言
    private String othBank;    //振込先銀行を宣言
    private String officeName;        //振込先支店を宣言
    private String depositAccount;        //預金科目を宣言
    private String accountNumber;        //振込口座番号を宣言
    private int tranAmount;    //振込額を宣言
    private final int tranFree = 220;        //振込手数料を宣言し、220を代入


//振込先の銀行と支店の入力
    public void payeeBank() {
       Bank b1 = new Bank("楽天","支店","普通"); //銀行のインスタンスを作成
       Bank b2 = new Bank("住信SBI","本店","普通");
       Bank b3 = new Bank("住信SBI","支店","普通");
        List<Bank> list = new LinkedList<>(); //銀行をコネクションの要素に格納する
        list.add(b1);
        list.add(b2);
        list.add(b3);
         System.out.println("振込先銀行の入力をしてください。"); //振込先銀行の入力
        this.othBank = new java.util.Scanner(System.in).nextLine();
        if (this.othBank.matches("[^[A-Zぁ-んァ-ヶア-ン゙゚一-龠]*$]{2,10}")) {
            for (Bank b : list) {
                 if (b.getSearchBankName() == null) {
                     throw new IllegalArgumentException("再度銀行名を入力してください");
                 }
                 if (this.othBank.equals(b.getSearchBankName())) {
                     break;                        
                 }
            }        
        }else {
            throw new IllegalArgumentException("銀行名はひらがな、カタカナ、漢字の2文字以上10文字以内です");
        }
        System.out.println("振込先支店の入力をしてください"); //振込先支店の入力
        this.officeName = new java.util.Scanner(System.in).nextLine();
        if (this.officeName.matches("[^[A-Zぁ-んァ-ヶア-ン゙゚一-龠]*$]{2,10}")) {
            for(Bank b : list) {
                if (b.getSearchOfficeName() == null) {
                    throw new IllegalArgumentException("再度支店名を入力してください");
                }
                if (this.othBank.equals(b.getSearchBankName())&&this.officeName.equals(b.getSearchOfficeName())){
                    break;
                }
            }            
        }else {
            throw new IllegalArgumentException("支店名はひらがな、カタカナ、漢字の2文字以上10文字以内です");
        }
        System.out.println("預金科目の普通か総合のどちらかを入力してください。"); //振込先の預金科目を入力
        this.depositAccount = new java.util.Scanner(System.in).nextLine();
        if (this.depositAccount.matches("[^[一-龠]*$]{2}")) {
            for(Bank b : list) {
                if (b.getSearchDepositAccount() == null) {
                        throw new IllegalArgumentException("預金科目を再入力してください");
                }
                if (this.othBank.equals(b.getSearchBankName())&&this.officeName.equals(b.getSearchOfficeName())&&this.depositAccount.equals(b.searchDepositAccount)) {
                    break;
                } 
            }
        }else {
            throw new IllegalArgumentException("普通か総合を入力してください");
        }
        System.out.println("相手の口座番号を入力してください"); //振込先の口座番号の入力
        this.accountNumber = new java.util.Scanner(System.in).nextLine();
        if (!this.accountNumber.matches("[0-9]{5,8}")) {
            throw new IllegalArgumentException("5から8桁の数字を入力をしてください");
        }
        System.out.println("振込額を入力してください"); //振込先への入金額を入力
        this.tranAmount = new java.util.Scanner(System.in).nextInt();
        if(this.tranAmount <= 0 ) {
            throw new IllegalArgumentException("振込額を入力してください");
        } else if( this.blance < this.tranAmount + this.tranFree) {
            throw new IllegalArgumentException("残高以上の支払いはできません");
        } 

         /**
         * 最終確認画面
         * @param blance 残高
         * @param tranAmount 振込額
         * @param tranFree 振込手数料
         * */
        System.out.println("振込先銀行      " + this.othBank);
        System.out.println("振込先支店      " + this.officeName);
        System.out.println("振込先預金科目  " + this.depositAccount);
        System.out.println("振込先口座番号  " + this.accountNumber);
        System.out.printf("振込金額        %,d円\n",this.tranAmount);
        System.out.printf("手数料          %d円\n",this.tranFree);
        System.out.println("この内容でよろしいでしょうか ");
        System.out.println("1:OK   2:やり直し");
        int k = new java.util.Scanner(System.in).nextInt();
        if (k == 1) {
            this.blance = this.blance - this.tranAmount - this.tranFree;
            System.out.println("振込は、今日の14時前は今日中で、14時以降は翌営業日になります\n");
            }else if(k == 2) {
                System.out.println("最初からの再入力をお願いします");
                this.payeeBank();
            }else {
                throw new IllegalArgumentException("1か2を選択してください");
            }
    }

 

     public int getBlance() {
        return this.blance;
    }

    public void setBlance(int blance) {
        this.blance = blance;
    }
    
    public String getOthBank() {
        return this.othBank;
    }
    public void setOthBank(String othBank) {
        this.othBank = othBank;
    }
    public String getOfficeName() {
        return this.officeName;
    }
    public void setOfficeName(String officeName) {
        this.officeName = officeName;
    }
    public String getDepositAccount() {
        return this.depositAccount;
    }
    public void setDepositAccount(String depositAccount) {
        this.depositAccount = depositAccount;
    }
    public String getAccountNumber() {
        return this.accountNumber;
    }
    public void setAccountNumber(String othaccountNumber) {
        this.accountNumber = othaccountNumber;
    }
    public int getTranAmount() {
        return this.tranAmount;
    }
    public void setTranAmount(int tranAmount) {
        this.tranAmount = tranAmount;
    }
    public int getTranFree() {
        return this.tranFree;
    }
}

 

package 銀行;

public class BalanceInquiry {
    private int blance;    //残高を宣言

//残高照会
        public void viewBalance() {
            System.out.println("残高 " + this.blance + "円");
        }
        
        public int getBlance() {
            return this. blance;
        }

        public void setBlance(int blance) {
            this.blance = blance;
        }
}

 

package 銀行;

import java.util.Map;
import java.util.TreeMap;

public class Customer {
    private String name;    //お客様の名前を宣言
    private String bankName; //お客様の銀行名を宣言
    private String officeName; //お客様の本支店を宣言
    private int blance;    //お客様の残高の宣言
    private String id;        //お客様のIDを宣言
    private int password;    //お客様のパスワードを宣言
    private Map<Integer,Customer> list; //お客様情報を宣言
     
    public Customer(String name, int blance, String id, int password,  String bankName, String officeName) {
        this.name = name;
        this.blance = blance;
        this.id = id;
        this.password = password;
        this.bankName = bankName;
        this.officeName = officeName;
    }
    
    public Customer() {
        
    }
    
    public Customer customerMatch() {
        Customer c1 = new Customer("愛甲",10000,"aikou",12365,"〇〇銀行", "本店"); //会員のインスタンスを生成
        Customer c2 = new Customer("伊田",5000,"ida",98745,"〇〇銀行", "本店");
        Customer c3 = new Customer("宇賀",15000,"uga",45698,"〇〇銀行", "支店");
        list = new TreeMap<>(); //会員をコネクションの要素に格納する
        list.put(1,c1);
        list.put(2,c2);
        list.put(3,c3);
        
      //お客様情報呼び出し
        System.out.println("ログインIDを入力してください");
        id = new java.util.Scanner(System.in).nextLine();
        System.out.println("パスワードを入力してください");
        password = new java.util.Scanner(System.in).nextInt();
        for(int i : list.keySet()) {
            Customer c = list.get(i);
           if (c == null) {
                throw new IllegalArgumentException("ログインできませんでした");
            } else if(this.id.equals(c.id) && this.password == c.password){
                return list.get(i);
            }
        }
        return null;
    }

 


    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBankName() {
        return this.bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    public String getOfficeName() {
        return this.officeName;
    }

    public void setOfficeName(String officeName) {
        this.officeName = officeName;
    }
    
    public int getBlance() {
        return this.blance;
    }

    public void setBlance(int blance) {
        this.blance = blance;
    }

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getPassword() {
        return this.password;
    }

    public void setPassword(int password) {
        this.password = password;
    }
}

 

package 銀行;

public class Bank {
    String searchBankName;    //銀行の名前を宣言
    String searchOfficeName; //銀行の支店を宣言
    String searchDepositAccount; //銀行の預金科目を宣言

    public Bank(String bankName, String officeName, String depositAccount) {
        this.searchBankName = bankName;
        this.searchOfficeName = officeName;
        this.searchDepositAccount = depositAccount;
    }

    public String getSearchBankName() {
        return this.searchBankName;
    }

    public void setSearchBankName(String searchBankName) {
        this.searchBankName = searchBankName;
    }

    public String getSearchOfficeName() {
        return this.searchOfficeName;
    }

    public void setSearchOfficeName(String searchOfficeName) {
        this.searchOfficeName = searchOfficeName;
    }

    public String getSearchDepositAccount() {
        return this.searchDepositAccount;
    }

    public void setSearchDepositAccount(String searchDepositAccount) {
        this.searchDepositAccount = searchDepositAccount;
    }
}