-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
175 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...nt/src/main/java/sopt/org/firstSeminarAdvancedAssignment/controller/ClientController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package sopt.org.firstSeminarAdvancedAssignment.controller; | ||
|
||
import sopt.org.firstSeminarAdvancedAssignment.service.ClientService; | ||
import sopt.org.firstSeminarAdvancedAssignment.view.InputView; | ||
import sopt.org.firstSeminarAdvancedAssignment.view.OutputView; | ||
|
||
public class ClientController { | ||
private final ClientService clientService = new ClientService(); | ||
private final InputView inputView = new InputView(); | ||
private final OutputView outputView = new OutputView(); | ||
|
||
|
||
public void registerClient() { | ||
outputView.inputClientInfoMessage(); | ||
clientService.registerClient(inputView.inputAccountNumber(), inputView.inputClientName(), inputView.inputBirth(), inputView.inputTel(), inputView.inputAddress(), inputView.inputPassword()); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...vancedAssignment/src/main/java/sopt/org/firstSeminarAdvancedAssignment/domain/Client.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package sopt.org.firstSeminarAdvancedAssignment.domain; | ||
|
||
public class Client { | ||
|
||
private String accountNumber; | ||
private String password; | ||
|
||
private int amount; | ||
private String name; | ||
private String birth; | ||
private String tel; | ||
private String address; | ||
|
||
|
||
public Client(String accountNumber, String password, String name, String birth, String tel, String address) { | ||
this.accountNumber = accountNumber; | ||
this.password = password; | ||
this.name = name; | ||
this.birth = birth; | ||
this.tel = tel; | ||
this.address = address; | ||
this.amount = 0; | ||
} | ||
|
||
public String getAccountNumber() { | ||
return accountNumber; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...nt/src/main/java/sopt/org/firstSeminarAdvancedAssignment/repository/ClientRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package sopt.org.firstSeminarAdvancedAssignment.repository; | ||
|
||
import sopt.org.firstSeminarAdvancedAssignment.domain.Client; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import static sopt.org.firstSeminarAdvancedAssignment.view.TextData.ACCOUNT_NUMBER_DUPLICATED_ERROR_MESSAGE; | ||
|
||
public class ClientRepository { | ||
private static final Map<String, Client> clientDB = new LinkedHashMap<>(); | ||
|
||
public void register(Client client) { | ||
boolean isDuplicated = false; | ||
|
||
for (String accountNumber : clientDB.keySet()) { | ||
if (client.getAccountNumber().equals(accountNumber)) { | ||
isDuplicated = true; | ||
break; | ||
} | ||
} | ||
|
||
if (isDuplicated) { | ||
throw new IllegalArgumentException(ACCOUNT_NUMBER_DUPLICATED_ERROR_MESSAGE); | ||
} | ||
|
||
clientDB.put(client.getAccountNumber(), client); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...signment/src/main/java/sopt/org/firstSeminarAdvancedAssignment/service/ClientService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package sopt.org.firstSeminarAdvancedAssignment.service; | ||
|
||
import sopt.org.firstSeminarAdvancedAssignment.domain.Client; | ||
import sopt.org.firstSeminarAdvancedAssignment.repository.ClientRepository; | ||
|
||
public class ClientService { | ||
private final ClientRepository clientRepository = new ClientRepository(); | ||
|
||
public void registerClient(String accountNumber, String name, String birth, String tel, String address, String password) { | ||
Client client = new Client(accountNumber, name, birth, tel, address, password); | ||
clientRepository.register(client); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ancedAssignment/src/main/java/sopt/org/firstSeminarAdvancedAssignment/view/InputView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package sopt.org.firstSeminarAdvancedAssignment.view; | ||
|
||
import java.util.Scanner; | ||
|
||
public class InputView { | ||
private Scanner sc = new Scanner(System.in); | ||
private final OutputView outputView = new OutputView(); | ||
|
||
public String inputAccountNumber() { | ||
outputView.inputAccountNumberForRegisterMessage(); | ||
return inputString(); | ||
} | ||
|
||
public String inputClientName() { | ||
outputView.inputClientNameForRegisterMessage(); | ||
return inputString(); | ||
} | ||
|
||
public String inputPassword() { | ||
outputView.inputPasswordForRegisterMessage(); | ||
return inputString(); | ||
} | ||
|
||
public String inputBirth() { | ||
outputView.inputBirthForRegisterMessage(); | ||
return inputString(); | ||
} | ||
|
||
public String inputTel() { | ||
outputView.inputTelNumberForRegisterMessage(); | ||
return inputString(); | ||
} | ||
|
||
public String inputAddress() { | ||
outputView.inputAddressForRegisterMessage(); | ||
return inputString(); | ||
} | ||
|
||
|
||
private String inputString() { | ||
return sc.nextLine(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ncedAssignment/src/main/java/sopt/org/firstSeminarAdvancedAssignment/view/OutputView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package sopt.org.firstSeminarAdvancedAssignment.view; | ||
|
||
public class OutputView { | ||
|
||
public final void inputClientInfoMessage() { | ||
System.out.println("고객 등록을 위하여, 정보를 입력해주세요."); | ||
} | ||
|
||
public final void inputAccountNumberForRegisterMessage() { | ||
System.out.println("등록하실 계좌번호를 입력해주세요. (중복불가)"); | ||
} | ||
|
||
public final void inputClientNameForRegisterMessage() { | ||
System.out.println("이름을 입력해주세요."); | ||
} | ||
|
||
public final void inputBirthForRegisterMessage() { | ||
System.out.println("생년월일을 입력해주세요. (2000-01-01 형식)"); | ||
} | ||
|
||
public final void inputTelNumberForRegisterMessage() { | ||
System.out.println("전화번호를 입력해주세요. (010-1234-1234 형식)"); | ||
} | ||
|
||
public final void inputAddressForRegisterMessage() { | ||
System.out.println("거주지 주소를 입력해주세요."); | ||
} | ||
|
||
public final void inputPasswordForRegisterMessage() { | ||
System.out.println("사용하실 비밀번호를 입력해주세요."); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...vancedAssignment/src/main/java/sopt/org/firstSeminarAdvancedAssignment/view/TextData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package sopt.org.firstSeminarAdvancedAssignment.view; | ||
|
||
public class TextData { | ||
|
||
public static final String ACCOUNT_NUMBER_DUPLICATED_ERROR_MESSAGE = "이미 존재하는 계좌번호입니다. 다른 번호를 사용해주세요."; | ||
} |