diff --git a/assignments/first_week/.DS_Store b/assignments/first_week/.DS_Store
new file mode 100644
index 0000000..9d0eeb3
Binary files /dev/null and b/assignments/first_week/.DS_Store differ
diff --git a/assignments/first_week/.gradle/7.4/checksums/checksums.lock b/assignments/first_week/.gradle/7.4/checksums/checksums.lock
new file mode 100644
index 0000000..e126b75
Binary files /dev/null and b/assignments/first_week/.gradle/7.4/checksums/checksums.lock differ
diff --git a/assignments/first_week/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock b/assignments/first_week/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock
new file mode 100644
index 0000000..5707254
Binary files /dev/null and b/assignments/first_week/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock differ
diff --git a/assignments/first_week/.gradle/7.4/dependencies-accessors/gc.properties b/assignments/first_week/.gradle/7.4/dependencies-accessors/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/assignments/first_week/.gradle/7.4/executionHistory/executionHistory.bin b/assignments/first_week/.gradle/7.4/executionHistory/executionHistory.bin
new file mode 100644
index 0000000..f98528f
Binary files /dev/null and b/assignments/first_week/.gradle/7.4/executionHistory/executionHistory.bin differ
diff --git a/assignments/first_week/.gradle/7.4/executionHistory/executionHistory.lock b/assignments/first_week/.gradle/7.4/executionHistory/executionHistory.lock
new file mode 100644
index 0000000..2e61a4e
Binary files /dev/null and b/assignments/first_week/.gradle/7.4/executionHistory/executionHistory.lock differ
diff --git a/assignments/first_week/.gradle/7.4/fileChanges/last-build.bin b/assignments/first_week/.gradle/7.4/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/assignments/first_week/.gradle/7.4/fileChanges/last-build.bin differ
diff --git a/assignments/first_week/.gradle/7.4/fileHashes/fileHashes.bin b/assignments/first_week/.gradle/7.4/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..62f0619
Binary files /dev/null and b/assignments/first_week/.gradle/7.4/fileHashes/fileHashes.bin differ
diff --git a/assignments/first_week/.gradle/7.4/fileHashes/fileHashes.lock b/assignments/first_week/.gradle/7.4/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..a57462b
Binary files /dev/null and b/assignments/first_week/.gradle/7.4/fileHashes/fileHashes.lock differ
diff --git a/assignments/first_week/.gradle/7.4/fileHashes/resourceHashesCache.bin b/assignments/first_week/.gradle/7.4/fileHashes/resourceHashesCache.bin
new file mode 100644
index 0000000..6a9b833
Binary files /dev/null and b/assignments/first_week/.gradle/7.4/fileHashes/resourceHashesCache.bin differ
diff --git a/assignments/first_week/.gradle/7.4/gc.properties b/assignments/first_week/.gradle/7.4/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/assignments/first_week/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/assignments/first_week/.gradle/buildOutputCleanup/buildOutputCleanup.lock
new file mode 100644
index 0000000..70e49ef
Binary files /dev/null and b/assignments/first_week/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/assignments/first_week/.gradle/buildOutputCleanup/cache.properties b/assignments/first_week/.gradle/buildOutputCleanup/cache.properties
new file mode 100644
index 0000000..13d10f1
--- /dev/null
+++ b/assignments/first_week/.gradle/buildOutputCleanup/cache.properties
@@ -0,0 +1,2 @@
+#Wed Apr 12 23:09:25 KST 2023
+gradle.version=7.4
diff --git a/assignments/first_week/.gradle/buildOutputCleanup/outputFiles.bin b/assignments/first_week/.gradle/buildOutputCleanup/outputFiles.bin
new file mode 100644
index 0000000..20506cb
Binary files /dev/null and b/assignments/first_week/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/assignments/first_week/.gradle/file-system.probe b/assignments/first_week/.gradle/file-system.probe
new file mode 100644
index 0000000..02c3320
Binary files /dev/null and b/assignments/first_week/.gradle/file-system.probe differ
diff --git a/assignments/first_week/.gradle/vcs-1/gc.properties b/assignments/first_week/.gradle/vcs-1/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/assignments/first_week/.idea/aws.xml b/assignments/first_week/.idea/aws.xml
new file mode 100644
index 0000000..99de319
--- /dev/null
+++ b/assignments/first_week/.idea/aws.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assignments/first_week/.idea/checkstyle-idea.xml b/assignments/first_week/.idea/checkstyle-idea.xml
new file mode 100644
index 0000000..d8d6852
--- /dev/null
+++ b/assignments/first_week/.idea/checkstyle-idea.xml
@@ -0,0 +1,15 @@
+
+
+
+ 10.3.4
+ JavaOnly
+
+
+
+
+ (bundled)
+ (bundled)
+
+
+
+
\ No newline at end of file
diff --git a/assignments/first_week/.idea/codeStyles/codeStyleConfig.xml b/assignments/first_week/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..54b41b0
--- /dev/null
+++ b/assignments/first_week/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/assignments/first_week/.idea/compiler.xml b/assignments/first_week/.idea/compiler.xml
new file mode 100644
index 0000000..fb7f4a8
--- /dev/null
+++ b/assignments/first_week/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assignments/first_week/.idea/gradle.xml b/assignments/first_week/.idea/gradle.xml
new file mode 100644
index 0000000..611e7c8
--- /dev/null
+++ b/assignments/first_week/.idea/gradle.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assignments/first_week/.idea/jarRepositories.xml b/assignments/first_week/.idea/jarRepositories.xml
new file mode 100644
index 0000000..fdc392f
--- /dev/null
+++ b/assignments/first_week/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assignments/first_week/.idea/jpa-buddy.xml b/assignments/first_week/.idea/jpa-buddy.xml
new file mode 100644
index 0000000..966d5f5
--- /dev/null
+++ b/assignments/first_week/.idea/jpa-buddy.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assignments/first_week/.idea/misc.xml b/assignments/first_week/.idea/misc.xml
new file mode 100644
index 0000000..4b106ac
--- /dev/null
+++ b/assignments/first_week/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assignments/first_week/.idea/vcs.xml b/assignments/first_week/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/assignments/first_week/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assignments/first_week/.idea/workspace.xml b/assignments/first_week/.idea/workspace.xml
new file mode 100644
index 0000000..537a276
--- /dev/null
+++ b/assignments/first_week/.idea/workspace.xml
@@ -0,0 +1,167 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "keyToString": {
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "WebServerToolWindowFactoryState": "false",
+ "last_opened_file_path": "/Users/jinseunghui/Documents/sopt/JinSeungHee/assignments/first_week",
+ "nodejs_package_manager_path": "npm",
+ "settings.editor.selected.configurable": "preferences.sourceCode.Java"
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1681306502928
+
+
+ 1681306502928
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assignments/first_week/README.md b/assignments/first_week/README.md
new file mode 100644
index 0000000..715a438
--- /dev/null
+++ b/assignments/first_week/README.md
@@ -0,0 +1,66 @@
+## 💸 객체지향 개념을 활용하여 은행 구현해보기
+
+## 기능 명세
+
+### 사용자
+
+- [x] 회원가입
+- [x] 입금
+- [x] 출금
+
+### 계좌
+
+- [x] 계좌 개설
+- [x] 계좌번호 랜덤 생성 기능
+
+## 객체들의 역할 -> SRP
+
+- 하나의 객체가 하나의 역할만 하도록 역할을 분리
+
+### Account 관련
+
+1. Account : 계좌에 대하여 정의
+2. AccountRepository : 계좌 관련 DB 저장 및 조회
+3. AccountType : 계좌의 종류에 대하여 정의
+4. TransactionType : 계좌를 이용한 거래의 종류에 대하여 정의
+5. AccountRegisterDto : 계좌를 등록할 시에 사용하는 dto
+6. AccountService : 저축 계좌, 입출금 계좌에 공통적으로 사용되는 비지니스 로직 명시
+7. ChequingAccountService : 입출금 계좌에 사용되는 비지니스 로직 구현
+8. SavingsAccountService : 저축계좌에 사용되는 비지니스 로직 구현
+9. AccountController : 클라이언트로부터 들어온 계좌 관련 요청을 처리
+10. LogGenerator : 계좌 거래 기록을 위해 일정한 형태로 가공
+11. NumberGenerator : 계좌번호를 난수로 생성
+
+### User 관련
+
+1. User : 사용자에 대하여 정의
+2. UserRepository : 사용자 관련 DB 저장 및 조회
+3. UserService : 사용자 관련 비지니스 로직 구현
+4. UserRegisterDto : 사용자 등록 시에 사용하는 dto
+5. UserController : 클라이언트로부터 들어온 사용자 관련 요청을 처리
+
+### 기타
+
+1. CommandSign : 사용자의 입력값의 의미와 사인에 대하여 저장
+2. BankController : 클라이언트의 요청을 처리
+3. BankView : 입출력
+
+## 활용 개념
+
+1. 캡슐화
+
+- UserRegisterDto, AccountRegisterDto: Dto 를 이용하여 클라이언트의 입력값을 캡슐화
+
+1. 변경될 필요가 없는 파라미터에 안정성을 위해 final 키워드 사용
+2. 전역적으로 접근할 수 있는 상수는 static final 이용
+ - 계좌번호 관련 정보, 계좌 개설 가능 연령
+ - 클라이언트가 입력하는 입력값에 대한 정보
+3. 다형성
+ - 계좌를 저축 / 입출금 계좌로 나누어 인터페이스에 정의된 register, deposit, withdraw 와 같은 공통적인 메서드들을 계좌의 타입에 따라서 다르게 구현
+4. 추상화
+
+- 인터페이스를 이용하여 저축 / 입출금 계좌에서 필요한 공통적인 메서드들을 정의
+
+5. 리스코브 치환의 원칙
+
+- SavingsAccountService, ChequingAccountService 모두 AccountService로 대체될 수 있음
\ No newline at end of file
diff --git a/assignments/first_week/build.gradle b/assignments/first_week/build.gradle
new file mode 100644
index 0000000..f73c67e
--- /dev/null
+++ b/assignments/first_week/build.gradle
@@ -0,0 +1,19 @@
+plugins {
+ id 'java'
+}
+
+group 'org.bank'
+version '1.0-SNAPSHOT'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
+}
+
+test {
+ useJUnitPlatform()
+}
\ No newline at end of file
diff --git a/assignments/first_week/build/tmp/compileJava/previous-compilation-data.bin b/assignments/first_week/build/tmp/compileJava/previous-compilation-data.bin
new file mode 100644
index 0000000..d295034
Binary files /dev/null and b/assignments/first_week/build/tmp/compileJava/previous-compilation-data.bin differ
diff --git a/assignments/first_week/gradle/.DS_Store b/assignments/first_week/gradle/.DS_Store
new file mode 100644
index 0000000..8e8eb40
Binary files /dev/null and b/assignments/first_week/gradle/.DS_Store differ
diff --git a/assignments/first_week/src/.DS_Store b/assignments/first_week/src/.DS_Store
new file mode 100644
index 0000000..2b39a72
Binary files /dev/null and b/assignments/first_week/src/.DS_Store differ
diff --git a/assignments/first_week/src/main/.DS_Store b/assignments/first_week/src/main/.DS_Store
new file mode 100644
index 0000000..92b0a3c
Binary files /dev/null and b/assignments/first_week/src/main/.DS_Store differ
diff --git a/assignments/first_week/src/main/java/BankController.java b/assignments/first_week/src/main/java/BankController.java
new file mode 100644
index 0000000..96b30f6
--- /dev/null
+++ b/assignments/first_week/src/main/java/BankController.java
@@ -0,0 +1,45 @@
+import static common.vo.CommandSign.ACCOUNT_DEPOSIT_SIGN;
+import static common.vo.CommandSign.ACCOUNT_REGISTER_SIGN;
+import static common.vo.CommandSign.ACCOUNT_WITHDRAWAL_SIGN;
+import static common.vo.CommandSign.MEMBER_REGISTER_SIGN;
+
+import account.service.dto.AccountRegisterDto;
+import account.ui.AccountController;
+import common.vo.CommandSign;
+import user.controller.UserController;
+import user.service.dto.UserRegisterDto;
+
+public class BankController {
+ private AccountController accountController = new AccountController();
+ private UserController userController = new UserController();
+
+ private BankView view = new BankView();
+
+ public void run(final CommandSign commandSign) {
+ if (commandSign == MEMBER_REGISTER_SIGN) {
+ view.printCommandMessage(MEMBER_REGISTER_SIGN);
+
+ UserRegisterDto userRegisterDto = view.getUserRegisterInfo();
+ userController.register(userRegisterDto);
+
+ view.printSaveOkMessage();
+ } else if (commandSign == ACCOUNT_REGISTER_SIGN) {
+ view.printCommandMessage(ACCOUNT_REGISTER_SIGN);
+
+ AccountRegisterDto accountRegisterDto = view.getAccountRegisterInfo();
+ accountController.register(accountRegisterDto);
+
+ view.printSaveOkMessage();
+ } else if (commandSign == ACCOUNT_DEPOSIT_SIGN) {
+ view.printCommandMessage(ACCOUNT_DEPOSIT_SIGN);
+ long depositRequestAmount = view.getDepositRequestAmount();
+ accountController.deposit(depositRequestAmount);
+ } else if (commandSign == ACCOUNT_WITHDRAWAL_SIGN) {
+ view.printCommandMessage(ACCOUNT_WITHDRAWAL_SIGN);
+ long withdrawalRequestAmount = view.getWithdrawalRequestAmount();
+ accountController.withdrawal(withdrawalRequestAmount);
+ } else {
+ throw new IllegalArgumentException("잘못된 입력값을 입력하셨습니다.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/assignments/first_week/src/main/java/BankView.java b/assignments/first_week/src/main/java/BankView.java
new file mode 100644
index 0000000..a7d78c2
--- /dev/null
+++ b/assignments/first_week/src/main/java/BankView.java
@@ -0,0 +1,56 @@
+import account.domain.AccountType;
+import account.service.dto.AccountRegisterDto;
+import common.vo.CommandSign;
+import java.util.Scanner;
+import user.service.dto.UserRegisterDto;
+
+public class BankView {
+ private final Scanner sc = new Scanner(System.in);
+
+ public void printIntroMessage() {
+ System.out.println("==== 은행에 오신 것을 환영합니다. ====");
+ }
+
+ public void printCommandMessage(final CommandSign commandSign) {
+ System.out.println(commandSign.getMessage());
+ }
+
+ public void printSaveOkMessage() {
+ System.out.println("정상적으로 저장되었습니다.");
+ }
+
+ public int getCommandSignNumber() {
+ System.out.println("원하는 옵션을 선택해주세요 \n 1: 회원가입 2: 계좌 생성 3: 계좌 입금 4: 계좌 출금 \n 종료하시려면 0을 입력해주세요.");
+ return sc.nextInt();
+ }
+
+ public UserRegisterDto getUserRegisterInfo() {
+ System.out.print("성함을 입력해주세요 >> ");
+ String name = sc.next();
+ System.out.print("나이를 입력해주세요 >> ");
+ int age = sc.nextInt();
+ return new UserRegisterDto(name, age);
+ }
+
+ public AccountRegisterDto getAccountRegisterInfo() {
+ System.out.print("원하는 계좌의 형태를 입력해주세요 \n 1: 저축 계좌 2: 입출금 계좌");
+ int accountTypeNumber = sc.nextInt();
+ AccountType accountType = AccountType.findAccountTypeWithTypeNumber(accountTypeNumber);
+ if (accountType == AccountType.SAVINGS) {
+ System.out.print("몇달 뒤에 적금을 만료하시겠어요? >> ");
+ int durationMonth = sc.nextInt();
+ return new AccountRegisterDto(AccountType.SAVINGS, durationMonth);
+ }
+ return new AccountRegisterDto(AccountType.CHEQUING);
+ }
+
+ public long getDepositRequestAmount() {
+ System.out.println("원하는 입금 금액을 입력해주세요 >> ");
+ return sc.nextLong();
+ }
+
+ public long getWithdrawalRequestAmount() {
+ System.out.println("원하는 출금 금액을 입력해주세요 >> ");
+ return sc.nextLong();
+ }
+}
diff --git a/assignments/first_week/src/main/java/account/domain/Account.java b/assignments/first_week/src/main/java/account/domain/Account.java
new file mode 100644
index 0000000..d7d0a09
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/domain/Account.java
@@ -0,0 +1,74 @@
+package account.domain;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+
+// 역할 : 계좌에 대하여 정의한다.
+public class Account {
+ public static final int ACCOUNT_NUMBER_LENGTH = 13;
+ public static final int ACCOUNT_NUMBER_MIN = 0;
+ public static final int ACCOUNT_NUMBER_MAX = 9;
+ public static final int MAXIMUM_WITHDRAWAL_COUNT = 3;
+
+ private AccountType accountType;
+ private String accountNumber;
+ private LocalDateTime createdAt;
+ private long balance; // 잔액
+ private int withdrawalCount;
+ private LocalDate expirationDate;
+ private List logs = new ArrayList<>();
+
+ public void deposit(final long depositAmount) {
+ this.balance += depositAmount;
+ }
+
+ public void withdrawal(final long withdrawalAmount) {
+ this.balance -= withdrawalAmount;
+ }
+
+ public boolean isBalanceSufficient(final long withdrawalAmount) {
+ return this.balance >= withdrawalAmount;
+ }
+
+ public void addLog(String log) {
+ this.logs.add(log);
+ }
+
+ public Account() {
+ this.createdAt = LocalDateTime.now();
+ this.withdrawalCount = 0;
+ this.balance = 0;
+ }
+
+ public Account(final AccountType accountType, final String accountNumber, final int durationMonth) {
+ this();
+ this.accountType = accountType;
+ this.accountNumber = accountNumber;
+ this.expirationDate = LocalDate.now().plusMonths(durationMonth);
+ }
+
+ public Account(final AccountType accountType, final String accountNumber) {
+ this();
+ this.accountType = accountType;
+ this.accountNumber = accountNumber;
+ this.expirationDate = null;
+ }
+
+ public AccountType getAccountType() {
+ return accountType;
+ }
+
+ public long getBalance() {
+ return balance;
+ }
+
+ public int getWithdrawalCount() {
+ return withdrawalCount;
+ }
+
+ public LocalDate getExpirationDate() {
+ return expirationDate;
+ }
+}
diff --git a/assignments/first_week/src/main/java/account/domain/AccountRepository.java b/assignments/first_week/src/main/java/account/domain/AccountRepository.java
new file mode 100644
index 0000000..e69edab
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/domain/AccountRepository.java
@@ -0,0 +1,17 @@
+package account.domain;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AccountRepository {
+
+ public static List accounts = new ArrayList<>();
+
+ public void save(final Account account) {
+ accounts.add(account);
+ }
+
+ public Account findAccount() {
+ return accounts.get(accounts.size() - 1);
+ }
+}
diff --git a/assignments/first_week/src/main/java/account/domain/AccountType.java b/assignments/first_week/src/main/java/account/domain/AccountType.java
new file mode 100644
index 0000000..ecbeb4a
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/domain/AccountType.java
@@ -0,0 +1,31 @@
+package account.domain;
+
+import java.util.Arrays;
+import java.util.Objects;
+import java.util.function.Predicate;
+
+public enum AccountType {
+ SAVINGS(1, "저축"),
+ CHEQUING(2, "입출금");
+
+ private int typeNumber;
+ private String typeName;
+
+ AccountType(int typeNumber, String typeName) {
+ this.typeNumber = typeNumber;
+ this.typeName = typeName;
+ }
+
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ private static AccountType find(final Predicate predicate) {
+ return Arrays.stream(values()).filter(predicate).findAny().orElseThrow(IllegalArgumentException::new);
+ }
+
+ public static AccountType findAccountTypeWithTypeNumber(final int typeNumber) {
+ return find(e -> Objects.equals(e.typeNumber, typeNumber));
+ }
+}
diff --git a/assignments/first_week/src/main/java/account/domain/TransactionType.java b/assignments/first_week/src/main/java/account/domain/TransactionType.java
new file mode 100644
index 0000000..d345466
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/domain/TransactionType.java
@@ -0,0 +1,16 @@
+package account.domain;
+
+public enum TransactionType {
+ DEPOSIT("예금"),
+ WITHDRAWAL("출금");
+
+ private String typeString;
+
+ TransactionType(final String typeString) {
+ this.typeString = typeString;
+ }
+
+ public String getTypeString() {
+ return typeString;
+ }
+}
diff --git a/assignments/first_week/src/main/java/account/service/AccountService.java b/assignments/first_week/src/main/java/account/service/AccountService.java
new file mode 100644
index 0000000..577e70e
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/service/AccountService.java
@@ -0,0 +1,15 @@
+package account.service;
+
+import account.domain.Account;
+import account.domain.TransactionType;
+import account.service.dto.AccountRegisterDto;
+
+public interface AccountService {
+ void register(final AccountRegisterDto registerDto);
+
+ void deposit(final Account account, final long depositRequest);
+
+ void withdrawal(final Account account, final long withdrawalRequest);
+
+ void addLogs(final Account account, final TransactionType transactionType, final long amount);
+}
diff --git a/assignments/first_week/src/main/java/account/service/ChequingAccountService.java b/assignments/first_week/src/main/java/account/service/ChequingAccountService.java
new file mode 100644
index 0000000..bac5ae2
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/service/ChequingAccountService.java
@@ -0,0 +1,44 @@
+package account.service;
+
+import static account.util.NumberGenerator.generateAccountNumber;
+
+import account.domain.Account;
+import account.domain.AccountRepository;
+import account.domain.AccountType;
+import account.domain.TransactionType;
+import account.service.dto.AccountRegisterDto;
+import account.util.LogGenerator;
+
+public class ChequingAccountService implements AccountService {
+
+ private final AccountRepository accountRepository = new AccountRepository();
+
+ @Override
+ public void register(final AccountRegisterDto registerDto) {
+ String accountNumber = generateAccountNumber();
+ Account account = new Account(AccountType.CHEQUING, accountNumber);
+ accountRepository.save(account);
+ }
+
+ @Override
+ public void deposit(final Account account, final long depositRequest) {
+ account.deposit(depositRequest);
+ addLogs(account, TransactionType.DEPOSIT, depositRequest);
+ }
+
+ @Override
+ public void withdrawal(final Account account, final long withdrawalRequest) {
+ if (!account.isBalanceSufficient(withdrawalRequest)) {
+ throw new IllegalArgumentException("금액이 충분하지 않습니다.");
+ }
+ account.withdrawal(withdrawalRequest);
+ addLogs(account, TransactionType.WITHDRAWAL, withdrawalRequest);
+ }
+
+ @Override
+ public void addLogs(final Account account, final TransactionType transactionType, final long amount) {
+ String log = LogGenerator.generateLog(amount, AccountType.CHEQUING, transactionType, account.getBalance());
+ account.addLog(log);
+ System.out.println(log);
+ }
+}
diff --git a/assignments/first_week/src/main/java/account/service/SavingsAccountService.java b/assignments/first_week/src/main/java/account/service/SavingsAccountService.java
new file mode 100644
index 0000000..737bfa9
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/service/SavingsAccountService.java
@@ -0,0 +1,52 @@
+package account.service;
+
+import static account.domain.Account.MAXIMUM_WITHDRAWAL_COUNT;
+import static account.util.NumberGenerator.generateAccountNumber;
+
+import account.domain.Account;
+import account.domain.AccountRepository;
+import account.domain.AccountType;
+import account.domain.TransactionType;
+import account.service.dto.AccountRegisterDto;
+import account.util.LogGenerator;
+import java.time.LocalDate;
+
+public class SavingsAccountService implements AccountService {
+
+ private final AccountRepository accountRepository = new AccountRepository();
+
+ @Override
+ public void register(final AccountRegisterDto registerDto) {
+ String accountNumber = generateAccountNumber();
+ Account account = new Account(AccountType.SAVINGS, accountNumber, registerDto.getDurationMonth());
+ accountRepository.save(account);
+ }
+
+ @Override
+ public void deposit(final Account account, final long depositRequest) {
+ account.deposit(depositRequest);
+ addLogs(account, TransactionType.DEPOSIT, depositRequest);
+ }
+
+ @Override
+ public void withdrawal(final Account account, final long withdrawalRequest) {
+ if (account.getWithdrawalCount() >= MAXIMUM_WITHDRAWAL_COUNT) {
+ throw new IllegalArgumentException("긴급 출금을 더 이상 사용하실 수 없습니다. 만료일 이후에 출금이 가능합니다.");
+ }
+ if (LocalDate.now().isBefore(account.getExpirationDate())) {
+ throw new IllegalArgumentException("만료일이 아니므로 출금하실 수 없습니다.");
+ }
+ if (!account.isBalanceSufficient(withdrawalRequest)) {
+ throw new IllegalArgumentException("금액이 충분하지 않습니다.");
+ }
+ account.withdrawal(withdrawalRequest);
+ addLogs(account, TransactionType.WITHDRAWAL, withdrawalRequest);
+ }
+
+ @Override
+ public void addLogs(final Account account, final TransactionType transactionType, final long amount) {
+ String log = LogGenerator.generateLog(amount, AccountType.CHEQUING, transactionType, account.getBalance());
+ account.addLog(log);
+ System.out.println(log);
+ }
+}
diff --git a/assignments/first_week/src/main/java/account/service/dto/AccountRegisterDto.java b/assignments/first_week/src/main/java/account/service/dto/AccountRegisterDto.java
new file mode 100644
index 0000000..ce7564a
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/service/dto/AccountRegisterDto.java
@@ -0,0 +1,25 @@
+package account.service.dto;
+
+import account.domain.AccountType;
+
+public class AccountRegisterDto {
+ private AccountType accountType;
+ private int durationMonth;
+
+ public AccountType getAccountType() {
+ return accountType;
+ }
+
+ public int getDurationMonth() {
+ return durationMonth;
+ }
+
+ public AccountRegisterDto(final AccountType accountType, final int durationMonth) {
+ this.accountType = accountType;
+ this.durationMonth = durationMonth;
+ }
+
+ public AccountRegisterDto(final AccountType accountType) {
+ this.accountType = accountType;
+ }
+}
diff --git a/assignments/first_week/src/main/java/account/ui/AccountController.java b/assignments/first_week/src/main/java/account/ui/AccountController.java
new file mode 100644
index 0000000..d140ae3
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/ui/AccountController.java
@@ -0,0 +1,44 @@
+package account.ui;
+
+import account.domain.Account;
+import account.domain.AccountRepository;
+import account.domain.AccountType;
+import account.service.ChequingAccountService;
+import account.service.SavingsAccountService;
+import account.service.dto.AccountRegisterDto;
+
+public class AccountController {
+ private final SavingsAccountService savingsAccountService = new SavingsAccountService();
+ private final ChequingAccountService chequingAccountService = new ChequingAccountService();
+ private final AccountRepository accountRepository = new AccountRepository();
+
+ public void register(final AccountRegisterDto registerDto) {
+ if (registerDto.getAccountType().equals(AccountType.CHEQUING)) {
+ chequingAccountService.register(registerDto);
+ return;
+ }
+ if (registerDto.getAccountType().equals(AccountType.SAVINGS)) {
+ savingsAccountService.register(registerDto);
+ return;
+ }
+ throw new IllegalArgumentException("잘못된 입력값입니다.");
+ }
+
+ public void deposit(final long depositAmount) {
+ Account account = accountRepository.findAccount();
+ if (account.getAccountType() == AccountType.SAVINGS) {
+ savingsAccountService.deposit(account, depositAmount);
+ return;
+ }
+ chequingAccountService.deposit(account, depositAmount);
+ }
+
+ public void withdrawal(final long withdrawalRequestAmount) {
+ Account account = accountRepository.findAccount();
+ if (account.getAccountType() == AccountType.SAVINGS) {
+ savingsAccountService.withdrawal(account, withdrawalRequestAmount);
+ return;
+ }
+ chequingAccountService.withdrawal(account, withdrawalRequestAmount);
+ }
+}
diff --git a/assignments/first_week/src/main/java/account/util/LogGenerator.java b/assignments/first_week/src/main/java/account/util/LogGenerator.java
new file mode 100644
index 0000000..1e6c8c4
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/util/LogGenerator.java
@@ -0,0 +1,13 @@
+package account.util;
+
+import account.domain.AccountType;
+import account.domain.TransactionType;
+import java.time.LocalDateTime;
+
+public class LogGenerator {
+ public static String generateLog(final Long amount, final AccountType accountType, final TransactionType transactionType,
+ final long balance) {
+ return LocalDateTime.now() + ":" + accountType.getTypeName() + "통장 >> " + transactionType.getTypeString()
+ + " ) " + amount + "원 / 잔액 : " + balance;
+ }
+}
\ No newline at end of file
diff --git a/assignments/first_week/src/main/java/account/util/NumberGenerator.java b/assignments/first_week/src/main/java/account/util/NumberGenerator.java
new file mode 100644
index 0000000..925593b
--- /dev/null
+++ b/assignments/first_week/src/main/java/account/util/NumberGenerator.java
@@ -0,0 +1,19 @@
+package account.util;
+
+import static account.domain.Account.ACCOUNT_NUMBER_LENGTH;
+import static account.domain.Account.ACCOUNT_NUMBER_MAX;
+import static account.domain.Account.ACCOUNT_NUMBER_MIN;
+
+public class NumberGenerator {
+
+ public NumberGenerator() {
+ }
+
+ public static String generateAccountNumber() {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < ACCOUNT_NUMBER_LENGTH; i++) {
+ buf.append((int) (Math.random() * ACCOUNT_NUMBER_MAX) + ACCOUNT_NUMBER_MIN);
+ }
+ return buf.toString();
+ }
+}
diff --git a/assignments/first_week/src/main/java/common/vo/CommandSign.java b/assignments/first_week/src/main/java/common/vo/CommandSign.java
new file mode 100644
index 0000000..8207c3a
--- /dev/null
+++ b/assignments/first_week/src/main/java/common/vo/CommandSign.java
@@ -0,0 +1,37 @@
+package common.vo;
+
+import java.util.Arrays;
+import java.util.Objects;
+import java.util.function.Predicate;
+
+public enum CommandSign {
+ QUIT_SIGN(0, "프로그램을 종료합니다."),
+ MEMBER_REGISTER_SIGN(1, "회원가입을 선택하셨습니다."),
+ ACCOUNT_REGISTER_SIGN(2, "계좌 개설을 선택하셨습니다."),
+ ACCOUNT_DEPOSIT_SIGN(3, "계좌 입금을 선택하셨습니다."),
+ ACCOUNT_WITHDRAWAL_SIGN(4, "계좌 출금을 선택하셨습니다.");
+
+ private int signNumber;
+ private String message;
+
+ CommandSign(int signNumber, String message) {
+ this.signNumber = signNumber;
+ this.message = message;
+ }
+
+ public int getSignNumber() {
+ return signNumber;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ private static CommandSign find(final Predicate predicate) {
+ return Arrays.stream(values()).filter(predicate).findAny().orElseThrow(IllegalArgumentException::new);
+ }
+
+ public static CommandSign findCommandSignWithSignNumber(final int signNumber) {
+ return find(e -> Objects.equals(e.signNumber, signNumber));
+ }
+}
diff --git a/assignments/first_week/src/main/java/main.java b/assignments/first_week/src/main/java/main.java
new file mode 100644
index 0000000..5c706de
--- /dev/null
+++ b/assignments/first_week/src/main/java/main.java
@@ -0,0 +1,22 @@
+import static common.vo.CommandSign.QUIT_SIGN;
+
+import common.vo.CommandSign;
+
+public class main {
+ public static void main(String[] args) {
+
+ BankView view = new BankView();
+ BankController bankController = new BankController();
+
+ view.printIntroMessage();
+ while (true) {
+ int commandSignNumber = view.getCommandSignNumber();
+ CommandSign commandSign = CommandSign.findCommandSignWithSignNumber(commandSignNumber);
+ if (commandSign == QUIT_SIGN) {
+ view.printCommandMessage(QUIT_SIGN);
+ break;
+ }
+ bankController.run(commandSign);
+ }
+ }
+}
diff --git a/assignments/first_week/src/main/java/user/controller/UserController.java b/assignments/first_week/src/main/java/user/controller/UserController.java
new file mode 100644
index 0000000..a637fc5
--- /dev/null
+++ b/assignments/first_week/src/main/java/user/controller/UserController.java
@@ -0,0 +1,12 @@
+package user.controller;
+
+import user.service.UserService;
+import user.service.dto.UserRegisterDto;
+
+public class UserController {
+ private UserService userService = new UserService();
+
+ public void register(final UserRegisterDto userRegisterDto) {
+ userService.register(userRegisterDto);
+ }
+}
diff --git a/assignments/first_week/src/main/java/user/domain/User.java b/assignments/first_week/src/main/java/user/domain/User.java
new file mode 100644
index 0000000..0ffbf6c
--- /dev/null
+++ b/assignments/first_week/src/main/java/user/domain/User.java
@@ -0,0 +1,16 @@
+package user.domain;
+
+import account.domain.Account;
+import java.util.ArrayList;
+import java.util.List;
+
+public class User {
+ private String name;
+ private int age;
+ private List accounts = new ArrayList<>();
+
+ public User(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+}
\ No newline at end of file
diff --git a/assignments/first_week/src/main/java/user/domain/UserRepository.java b/assignments/first_week/src/main/java/user/domain/UserRepository.java
new file mode 100644
index 0000000..01d94f1
--- /dev/null
+++ b/assignments/first_week/src/main/java/user/domain/UserRepository.java
@@ -0,0 +1,12 @@
+package user.domain;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class UserRepository {
+ public static final List users = new ArrayList<>();
+
+ public void save(final User user) {
+ users.add(user);
+ }
+}
diff --git a/assignments/first_week/src/main/java/user/service/UserService.java b/assignments/first_week/src/main/java/user/service/UserService.java
new file mode 100644
index 0000000..b7b67cf
--- /dev/null
+++ b/assignments/first_week/src/main/java/user/service/UserService.java
@@ -0,0 +1,15 @@
+package user.service;
+
+import user.domain.User;
+import user.domain.UserRepository;
+import user.service.dto.UserRegisterDto;
+
+public class UserService {
+
+ private final UserRepository userRepository = new UserRepository();
+
+ public void register(final UserRegisterDto request) {
+ User user = new User(request.getName(), request.getAge());
+ userRepository.save(user);
+ }
+}
diff --git a/assignments/first_week/src/main/java/user/service/dto/UserRegisterDto.java b/assignments/first_week/src/main/java/user/service/dto/UserRegisterDto.java
new file mode 100644
index 0000000..22081af
--- /dev/null
+++ b/assignments/first_week/src/main/java/user/service/dto/UserRegisterDto.java
@@ -0,0 +1,23 @@
+package user.service.dto;
+
+
+public class UserRegisterDto {
+ private String name;
+ private int age;
+
+ public String getName() {
+ return name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public UserRegisterDto(
+ String name,
+ int age
+ ) {
+ this.name = name;
+ this.age = age;
+ }
+}