-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2주차]객체지향 코드 연습(Jungsukwoo) #27
Open
Jungsukwoo
wants to merge
46
commits into
COW-edu:main
Choose a base branch
from
Jungsukwoo:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
0f10b2e
feat: Appconfig 생성
Jungsukwoo 0f3bff6
feat: Controller에 필요한 의존성 주입
Jungsukwoo aad9909
feat: 로또 구매 메소드 생성
Jungsukwoo 0ab6887
feat: 로또 구매 갯수 파악, repository 저장 기능 구현
Jungsukwoo c1db8c3
feat: 로또 저장, 저장된 로또 목록 조회 메소드 생성
Jungsukwoo 01e6b20
feat: 로또 저장, 반환 로직 구현
Jungsukwoo 1732633
feat: 랜덤 로또번호 생성 구현
Jungsukwoo 101765e
feat: 당첨 번호 + 보너스 번호 입력 받는 메소드 생성
Jungsukwoo 66b3cc4
feat: 당첨 번호 + 보너스 번호 입력 받는 출력문 추가
Jungsukwoo 0a41997
feat: 당첨 로또번호 입력 및 저장 메소드 기능 구현
Jungsukwoo b3f1208
feat: 당첨 로또번호 저장 메소드 생성
Jungsukwoo 6acfb65
feat: 랜덤 로또 번호 저장소와 당첨 번호 저장소를 분리하여 저장
Jungsukwoo f9f43d7
feat: 로또 당첨번호 메소드 생성
Jungsukwoo 3e916f3
feat: 당첨 번호 입력 받을 수 있도록 서비스와 연결, 각 출력되어야 하는 메시지 추가
Jungsukwoo 37e1ece
feat: 예외처리 문구 추가
Jungsukwoo 37285df
feat: 예외처리 문구 추가 outputvew
Jungsukwoo ed4118b
feat: 금액 잘못 넣었을 때 문구 추가
Jungsukwoo 794e95a
feat: 로또 금액 잘못 넣었을 때 예외처리 로직 및 당첨 번호 잘못 넣었을 때 예외처리 로직 구현
Jungsukwoo 93f171e
feat: 당첨 번호 입력 이후 구매한 로또 갯수+랜덤 번호 출력 메소드 추가
Jungsukwoo 3e6801b
feat: 처음에는 단순히 저장할 메소드로 생각했으나 inputWinningNumbers에서 레파지토리에 저장메소드를 불러왔…
Jungsukwoo 004a334
feat: 모든 구매 로또와 당첨 로또번호를 비교 후 출력 기능 구현
Jungsukwoo d31c6e2
feat: 최종 결과 값 클래스 생성
Jungsukwoo e28771d
feat: 6개중 첫번째 당첨 번호 저장 기능
Jungsukwoo 1ed40b4
feat: 6개중 첫번째 당첨 번호 저장 기능
Jungsukwoo f27b5a4
feat: ErrorMessage 전용 enum 생성
Jungsukwoo 67aacf4
feat: 기존 에러 관련된 output 전부 제거
Jungsukwoo a9cbd09
feat: 코드 재사용성 및 유지보수성을 위한 상수 선언
Jungsukwoo f782cba
feat: 가독성을 위해 public 메소드를 상단으로 재배치
Jungsukwoo fa0b41f
feat: 열거형 에러 메세지 호출
Jungsukwoo 778f4ca
feat: 반복문의 조건을 변수로 선언하여 통제
Jungsukwoo 31aa2d9
feat: 상수 불변성을 위해 final 사용
Jungsukwoo 3449189
feat: 매직넘버를 상수로 선언, Enum으로 바꾼 에러 메시지 호출 메소드 수정
Jungsukwoo f7bdb02
feat: 중복된 문자열 정리
Jungsukwoo f789556
feat: 6개중 마지막 저장 번호 반환
Jungsukwoo 81f8e75
feat: while문 변수선언 방식으로 변경
Jungsukwoo 326660d
feat: 오타 수정
Jungsukwoo 6254b9a
feat: 불필요한 static 수정
Jungsukwoo 0e2bc0e
feat: 의존성 주입
Jungsukwoo 632b5d7
feat: 의존성 주입으로 불필요한 객체 선언 수정
Jungsukwoo 88c541c
feat: 로또 출력
Jungsukwoo 22ad9ff
Update README.md and other modified files
Jungsukwoo 4ef3fc3
feat: readme 파일 생성
Jungsukwoo 516dd84
feat: readme 파일 수정
Jungsukwoo d9d8837
feat: 오타 수정
Jungsukwoo 98a560c
feat: 내용 수정
Jungsukwoo ae0a4ff
feat: 파일수정
Jungsukwoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package lotto; | ||
|
||
import lotto.controller.LottoController; | ||
import lotto.repository.LottoRepository; | ||
import lotto.repository.LottoRepositoryImpl; | ||
import lotto.service.LottoService; | ||
import lotto.service.LottoServiceImpl; | ||
import lotto.view.InputView; | ||
import lotto.view.OutputView; | ||
|
||
import java.security.Provider; | ||
Jungsukwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public class AppConfig { | ||
|
||
public InputView inputView() { | ||
Jungsukwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return new InputView(); | ||
} | ||
|
||
public OutputView outputView() { | ||
return new OutputView(); | ||
} | ||
|
||
// LottoRepository 인스턴스를 생성하는 메서드 | ||
public LottoRepository lottoRepository() { | ||
return new LottoRepositoryImpl(); | ||
} | ||
|
||
public LottoService lottoService() { | ||
return new LottoServiceImpl(lottoRepository()); | ||
} | ||
|
||
public LottoController lottoController() { | ||
Jungsukwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return new LottoController(lottoService(), inputView(), outputView()); | ||
} | ||
|
||
} |
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,24 @@ | ||
package lotto.controller; | ||
|
||
import lotto.service.LottoService; | ||
import lotto.view.InputView; | ||
import lotto.view.OutputView; | ||
|
||
public class LottoController { | ||
|
||
private final LottoService lottoService; | ||
private final InputView inputView; | ||
private final OutputView outputView; | ||
|
||
public LottoController(LottoService lottoService, InputView inputView, OutputView outputView) { | ||
this.lottoService = lottoService; | ||
this.inputView = inputView; | ||
this.outputView = outputView; | ||
} | ||
Comment on lines
+13
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 생성자 주입을 사용하셨네요! 좋은 선택인 것 같습니다. 그래도 이유를 알면 좋으니 의존성 주입에는 다양한 방법이 있는데 생성자를 통해 의존성을 주입하신 이유에 대해 설명해주실 수 있을까요?? |
||
|
||
|
||
public void run() { | ||
|
||
} | ||
} | ||
|
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,9 @@ | ||
package lotto.repository; | ||
|
||
import lotto.model.Lotto; | ||
import java.util.List; | ||
|
||
public interface LottoRepository { | ||
void saveLotto(Lotto lotto); | ||
List<Lotto> findAllLotto(); | ||
} | ||
Jungsukwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
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,20 @@ | ||
package lotto.repository; | ||
|
||
import lotto.model.Lotto; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class LottoRepositoryImpl implements LottoRepository { | ||
|
||
private final List<Lotto> lottoStorage = new ArrayList<>(); | ||
Jungsukwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@Override | ||
public void saveLotto(Lotto lotto) { | ||
lottoStorage.add(lotto); | ||
} | ||
|
||
@Override | ||
public List<Lotto> findAllLotto() { | ||
return new ArrayList<>(lottoStorage); | ||
} | ||
} |
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,10 @@ | ||
package lotto.service; | ||
|
||
import lotto.model.Lotto; | ||
|
||
import java.util.List; | ||
|
||
public interface LottoService { | ||
List<Lotto> purchaseLotto(int amount); | ||
Jungsukwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
} |
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 lotto.service; | ||
import camp.nextstep.edu.missionutils.Randoms; | ||
import lotto.model.Lotto; | ||
import lotto.repository.LottoRepository; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class LottoServiceImpl implements LottoService { | ||
|
||
private final LottoRepository lottoRepository; | ||
|
||
public LottoServiceImpl(LottoRepository lottoRepository) { | ||
this.lottoRepository = lottoRepository; | ||
} | ||
|
||
@Override | ||
public List<Lotto> purchaseLotto(int amount) { | ||
int numberOfLotto = amount / 1000; | ||
Jungsukwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
List<Lotto> purchasedLotto = new ArrayList<>(); | ||
|
||
for (int i = 0; i < numberOfLotto; i++) { | ||
Jungsukwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
List<Integer> lottoNumbers = Randoms.pickUniqueNumbersInRange(1, 45, 6); | ||
Lotto lotto = new Lotto(lottoNumbers); | ||
Jungsukwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
purchasedLotto.add(lotto); | ||
} | ||
return purchasedLotto; | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppConfig를 통해 의존성을 관리하고 있는 것이 여러 의존 관계를 지닐 로또 미션에서 굉장히 좋은 선택이라는 생각이 듭니다.!
다만 아직까진 AppConfig은 그럼 어디서 생성해주고 관리해야할까요? 이것도 한번 고민해보시면 좋을것 같습니다!