Skip to content

Commit

Permalink
refactor: 매직 리터럴 제거 #1
Browse files Browse the repository at this point in the history
  • Loading branch information
PgmJun committed Apr 18, 2023
1 parent 1362709 commit 6cb8414
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
import sopt.org.firstSeminarAdvancedAssignment.controller.ClientController;

import static sopt.org.firstSeminarAdvancedAssignment.view.OutputView.printError;
import static sopt.org.firstSeminarAdvancedAssignment.view.TextData.WRONG_BANKING_JOB_ERROR_MESSAGE;
import static sopt.org.firstSeminarAdvancedAssignment.view.message.ErrorMessage.WRONG_BANKING_JOB_ERROR_MESSAGE;

public class BankProgram {
private static final String FUNC_REGISTER = "1";
private static final String FUNC_SHOW = "2";
private static final String FUNC_WITHDRAW = "3";
private static final String FUNC_DEPOSIT = "4";
private static final String FUNC_TRANSFER = "5";
private static final String FUNC_EXIT = "x";

private final ClientController clientController = new ClientController();


Expand All @@ -25,22 +32,22 @@ public void run() {
private boolean doBanking() {
boolean isRun = true;
switch (clientController.selectBankJob()) {
case "1":
case FUNC_REGISTER:
clientController.registerClient();
break;
case "2":
case FUNC_SHOW:
clientController.getClientAccountBalance();
break;
case "3":
case FUNC_WITHDRAW:
clientController.withdrawAccountBalance();
break;
case "4":
case FUNC_DEPOSIT:
clientController.depositMoneyIntoAccount();
break;
case "5":
case FUNC_TRANSFER:
clientController.transferMoneyToAnotherAccount();
break;
case "x":
case FUNC_EXIT:
isRun = false;
clientController.goOut();
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sopt.org.firstSeminarAdvancedAssignment.domain;

import static sopt.org.firstSeminarAdvancedAssignment.view.TextData.WRONG_ACCOUNT_NUMBER_FORMAT_ERROR_MESSAGE;
import static sopt.org.firstSeminarAdvancedAssignment.view.TextData.WRONG_TRANSFER_AMOUNT_ERROR_MESSAGE;
import static sopt.org.firstSeminarAdvancedAssignment.view.message.ErrorMessage.WRONG_ACCOUNT_NUMBER_FORMAT_ERROR_MESSAGE;
import static sopt.org.firstSeminarAdvancedAssignment.view.message.ErrorMessage.WRONG_TRANSFER_AMOUNT_ERROR_MESSAGE;

public class Client {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.LinkedHashMap;
import java.util.Map;

import static sopt.org.firstSeminarAdvancedAssignment.view.TextData.*;
import static sopt.org.firstSeminarAdvancedAssignment.view.message.ErrorMessage.*;

public class ClientRepository {
private static final Map<String, Client> clientDB = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sopt.org.firstSeminarAdvancedAssignment.domain.Client;
import sopt.org.firstSeminarAdvancedAssignment.repository.ClientRepository;

import static sopt.org.firstSeminarAdvancedAssignment.view.TextData.WRONG_ACCOUNT_BALANCE_AMOUNT_ERROR_MESSAGE;
import static sopt.org.firstSeminarAdvancedAssignment.view.message.ErrorMessage.WRONG_ACCOUNT_BALANCE_AMOUNT_ERROR_MESSAGE;

public class ClientService {
private final ClientRepository clientRepository = new ClientRepository();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Scanner;

import static sopt.org.firstSeminarAdvancedAssignment.view.TextData.WRONG_NUMBER_FORMAT_ERROR_MESSAGE;
import static sopt.org.firstSeminarAdvancedAssignment.view.message.ErrorMessage.WRONG_NUMBER_FORMAT_ERROR_MESSAGE;

public class InputView {
private final Scanner sc = new Scanner(System.in);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,118 +1,115 @@
package sopt.org.firstSeminarAdvancedAssignment.view;

import static sopt.org.firstSeminarAdvancedAssignment.view.message.OutputMessage.*;

public class OutputView {

// 고객 등록 메세지
public void printInputClientInfoMessage() {
printEnter();
System.out.println("고객 등록을 위하여, 정보를 입력해주세요.");
System.out.println(REGISTER_CLIENT_MESSAGE);
}

public void printInputAccountNumberForRegisterMessage() {
System.out.println("등록하실 계좌번호를 입력해주세요. (Integer-Integer-Integer 형식)");
System.out.println(INPUT_REGISTER_ACCOUNT_NUMBER_MESSAGE);
}

public void printInputBirthForRegisterMessage() {
System.out.println("생년월일을 입력해주세요. (2000-01-01 형식)");
System.out.println(INPUT_REGISTER_CLIENT_BIRTH_MESSAGE);
}

public void printInputTelNumberForRegisterMessage() {
System.out.println("전화번호를 입력해주세요. (010-1234-1234 형식)");
System.out.println(INPUT_REGISTER_CLIENT_TEL_MESSAGE);
}

public void printInputAddressForRegisterMessage() {
System.out.println("거주지 주소를 입력해주세요.");
System.out.println(INPUT_REGISTER_CLIENT_ADDRESS_MESSAGE);
}

public void printInputPasswordForRegisterMessage() {
System.out.println("사용하실 비밀번호를 입력해주세요. (6자)");
System.out.println(INPUT_REGISTER_CLIENT_PASSWORD_MESSAGE);
}


//잔액 조회 메세지
public void printCheckAccountBalanceMessage() {
printEnter();
System.out.println("잔액 조회를 위해 계좌번호와 비밀번호를 입력해주세요.");
System.out.println(CHECK_ACCOUNT_BALANCE_MESSAGE);
}

public void printClientAmountBalance(int amount) {
System.out.println("해당 계좌의 잔액은 " + amount + "원 입니다.");
public void printClientAmountBalance(int amount) { //! 메서드명 수정 필요
System.out.printf(CLIENT_ACCOUNT_BALANCE_AMOUNT_MESSAGE, amount);
printEnter();
}

//출금 메세지
public void printWithdrawAccountBalanceMessage() {
printEnter();
System.out.println("출금을 위해 계좌번호와 비밀번호를 입력해주세요.");
System.out.println(CLIENT_WITHDRAW_MESSAGE);
}

public void printWithdrawAmountMessage() {
System.out.println("출금하실 금액을 입력해주세요.");
System.out.println(INPUT_WITHDRAW_AMOUNT_MESSAGE);
}

public void printRemainAmountAfterWithdrawMessage(int amount) {
System.out.println("출금이 완료되었습니다.");
System.out.println("출금 후 잔액은 " + amount + "원 입니다.");
System.out.printf(WITHDRAW_SUCCESS_MESSAGE, amount);
}

//입금 메세지
public void printDepositIntoAccountMessage() {
printEnter();
System.out.println("입금을 위해 계좌번호를 입력해주세요.");
System.out.println(CLIENT_DEPOSIT_MESSAGE);
}

public void printDepositMoneyAmountMessage() {
System.out.println("입금하실 금액을 입력해주세요.");
System.out.println(INPUT_DEPOSIT_AMOUNT_MESSAGE);
}

public void printAmountAfterDeposit(int amount) {
System.out.println("입금 후 계좌 내 금액은 " + amount + "원 입니다.");
System.out.printf(DEPOSIT_SUCCESS_MESSAGE, amount);
printEnter();
}

//송금 메세지
public void printAnotherAccountToTransferMoneyMessage() {
System.out.println("돈을 송금할 계좌번호를 입력해주세요.");
System.out.println(CLIENT_TRANSFER_MESSAGE);
}

public void printTransferAmountMessage() {
System.out.println("송금하실 금액을 입력해주세요.");
System.out.println(INPUT_TRANSFER_AMOUNT_MESSAGE);
}

public void printRemainAmountAfterTransferMessage(int amount) {
System.out.println("송금이 완료되었습니다.");
System.out.println("송금 후 잔액은 " + amount + "원 입니다.");
System.out.printf(TRANSFER_SUCCESS_MESSAGE,amount);
printEnter();
}


//기본 메세지
public void printInputClientNameMessage() {
System.out.println("이름을 입력해주세요.");
System.out.println(INPUT_CLIENT_NAME_MESSAGE);
}

public void printInputAccountNumberMessage() {
System.out.println("계좌번호를 입력해주세요.");
System.out.println(INPUT_ACCOUNT_NUMBER_MESSAGE);
}

public void printInputPasswordMessage() {
System.out.println("비밀번호를 입력해주세요.");
System.out.println(INPUT_ACCOUNT_PASSWORD_MESSAGE);
}

public void printWelcomeMessage() {
System.out.println("반갑습니다 SOPT은행입니다. 무엇을 도와드릴까요?");
System.out.println(WELCOME_MESSAGE);
}

public void printExitMessage() {
System.out.println("안녕히가십시오.");
System.out.println(EXIT_MESSAGE);
}

public void printInputBankingJobMessage() {
printEnter();
System.out.println("은행 업무를 선택해주세요");
System.out.println("- 1: 계좌등록\n" +
"- 2: 잔액조회\n" +
"- 3: 출금\n" +
"- 4: 입금\n" +
"- 5: 송급\n" +
"- x: 종료");
System.out.println(INPUT_BANKING_JOB_MESSAGE);
}

private void printEnter() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sopt.org.firstSeminarAdvancedAssignment.view;
package sopt.org.firstSeminarAdvancedAssignment.view.message;

public class TextData {
public class ErrorMessage {

public static final String ACCOUNT_NUMBER_DUPLICATED_ERROR_MESSAGE = "이미 존재하는 계좌번호입니다. 다른 번호를 사용해주세요.";
public static final String WRONG_PASSWORD_ERROR_MESSAGE = "비밀번호가 틀렸습니다. 다시 시도해주세요.";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package sopt.org.firstSeminarAdvancedAssignment.view.message;

public class OutputMessage {

public final static String REGISTER_CLIENT_MESSAGE = "고객 등록을 위하여, 정보를 입력해주세요.";
public final static String INPUT_REGISTER_ACCOUNT_NUMBER_MESSAGE = "등록하실 계좌번호를 입력해주세요. (Integer-Integer-Integer 형정)";
public final static String INPUT_REGISTER_CLIENT_BIRTH_MESSAGE = "생년월일을 입력해주세요. (2000-01-01 형식)";
public final static String INPUT_REGISTER_CLIENT_TEL_MESSAGE = "전화번호를 입력해주세요. (010-1234-1234 형식)";
public final static String INPUT_REGISTER_CLIENT_ADDRESS_MESSAGE = "거주지 주소를 입력해주세요.";
public final static String INPUT_REGISTER_CLIENT_PASSWORD_MESSAGE = "사용하실 비밀번호를 입력해주세요. (6자)";

public final static String CHECK_ACCOUNT_BALANCE_MESSAGE = "잔액 조회를 위해 계좌번호와 비밀번호를 입력해주세요.";
public final static String CLIENT_ACCOUNT_BALANCE_AMOUNT_MESSAGE = "해당 계좌의 잔액은 %d원 입니다.";

public final static String CLIENT_WITHDRAW_MESSAGE = "출금을 위해 계좌번호와 비밀번호를 입력해주세요.";
public final static String INPUT_WITHDRAW_AMOUNT_MESSAGE = "출금하실 금액을 입력해주세요.";
public final static String WITHDRAW_SUCCESS_MESSAGE = "출금이 완료되었습니다.\n출금 후 잔액은 %d원 입니다.";

public final static String CLIENT_DEPOSIT_MESSAGE = "입금을 위해 계좌번호를 입력해주세요.";
public final static String INPUT_DEPOSIT_AMOUNT_MESSAGE = "입금하실 금액을 입력해주세요.";
public final static String DEPOSIT_SUCCESS_MESSAGE = "입금이 완료되었습니다.\n입금 후 계좌 내 금액은 %d원 입니다.";

public final static String CLIENT_TRANSFER_MESSAGE = "돈을 송금할 계좌번호를 입력해주세요.";
public final static String INPUT_TRANSFER_AMOUNT_MESSAGE = "송금하실 금액을 입력해주세요.";
public final static String TRANSFER_SUCCESS_MESSAGE = "송금이 완료되었습니다.\n송금 후 계좌 내 금액은 %d원 입니다.";


public final static String INPUT_CLIENT_NAME_MESSAGE = "이름을 입력해주세요.";
public final static String INPUT_ACCOUNT_NUMBER_MESSAGE = "계좌번호를 입력해주세요.";
public final static String INPUT_ACCOUNT_PASSWORD_MESSAGE = "비밀번호를 입력해주세요.";
public final static String WELCOME_MESSAGE = "반갑습니다 SOPT은행입니다. 무엇을 도와드릴까요?";
public final static String EXIT_MESSAGE = "안녕히가십시오.";
public final static String INPUT_BANKING_JOB_MESSAGE = "은행 업무를 선택해주세요\n" +
"- 1: 계좌등록\n" +
"- 2: 잔액조회\n" +
"- 3: 출금\n" +
"- 4: 입금\n" +
"- 5: 송급\n" +
"- x: 종료";






}

0 comments on commit 6cb8414

Please sign in to comment.