Skip to content

Conversation

@Timothy-Y-H-Lee
Copy link

No description provided.

Timothy added 19 commits November 3, 2025 18:04
# style(lotto): add gitignore configuration

- Java: '.class' 추가
# Java: added '.class' to gitignore
# style(lotto): Add gitignore configuration

- Java: '.class' 추가
# Java: added '.class' to gitignore
# docs: Update feature list

1. 상수값 정의: 세부 기능 항목들을 작성.
   # Define constant values: list detailed feature items.

2. 로또 번호 생성기
   # Lotto number generator.

3. inputView를 통해, 추첨자의 당첨번호와 보너스 번호 입력값 받기
   # Receive the winning and bonus numbers from the user through inputView.

4. 입력값에 대한 테스트 케이스 작성
   # Write test cases for input validation.

5. 사용자의 입력값과 비교
   # Compare user input with winning numbers.

6. 출력용 View를 이용해서 출력
   # Display results using the output View.
# feat: Define constant values

1. 상수값 정의: 게임 규칙과 사용자 인터페이스 메시지 작성.
   # Define constant values for game rules and user interface messages.
# docs: Update feature list

- "2. 로또 번호 생성기" 항목 추가
  # Added item "2. Lotto number generator" to the feature list
- 중복되지 않는 6개의 숫자 생성 후, 오름차순으로 저장
> - LottoPublishServiceTest : "중복되지_않는_6개의_숫자_생성" Test case 생성
> - LottoPublishService : 중복되지 않는 6개의 숫자 생성 후, Lotto에 오름차순으로 저장
> - Lotto(List<Integer> numbers) 생성자에서 validate(List<Integer> numbers)사용시, 유효성 검증 강화.
# feat: Issue and store lotto games based on purchase amount in the Service layer

- 1개의 보너스 번호 저장
  # Store one bonus number

- 보너스 번호를 입력받아서 검증
  # Receive and validate the bonus number

Closes #2
# docs: Update feature list

- 3. 추첨자의 입력값 처리
  # 3. Handle the input values from the lottery drawer
# feat: Handle the input values from the lottery buyer

- 로또 구입 금액을 입력받아서 검증
  # Receive and validate the purchase amount for lotto tickets

> - InputView에서 로또 구입 금액을 받아서 LottoController로 전달
>   # InputView receives the purchase amount and passes it to LottoController

> - 로또 발행 시, 구입 금액만큼 로또 발행
>   # Issue lotto tickets equal to the purchase amount

> - "구매_금액_테스트" Test case의 테스트
>   # Test the "Purchase_Amount_Test" test case

- outputView로 출력
  # Display output through outputView

> - "n개를 구매했습니다."
>   # "Purchased n tickets."
# feat: Handle the input values from the lottery buyer

- outputView로 출력
  # Display output through outputView

> - 로또 구입 금액에 따른 구매 내역 출력 (발행한 로또 수량 및 번호를 출력한다. 로또 번호는 오름차순으로 정렬하여 보여준다.)
>   # Print the purchase details based on the purchase amount (display the number of issued lotto tickets and their numbers, sorted in ascending order)
# feat: Handle the input values from the lottery buyer

- 로또 번호에 중복된 숫자 처리
  # Handle duplicate numbers in lotto tickets
# feat: Handle the input values from the lottery buyer

- 추첨자의 로또 당첨 번호 6개를 입력받아서 검증
  # Receive and validate six winning numbers from the lottery buyer

> - "잘못된_당첨_번호_형식" Test case
>   # "Invalid_Winning_Number_Format" test case

> - "당첨_번호_개수_잘못_입력" Test case
>   # "Incorrect_Winning_Number_Count" test case

> - "당첨_번호_입력_개수_체크" Test case
>   # "Winning_Number_Input_Count_Check" test case
# feat: Handle the input values from the lottery buyer

- 추첨자의 보너스 번호 입력값 1개를 입력받아서 검증
  # Receive and validate one bonus number input from the lottery buyer

> - MVC 패턴으로 보너스 번호 입력값 받기
>   # Receive the bonus number input through the MVC pattern

> - 추첨자의 보너스 번호 1개 입력받아서 저장
>   # Accept and store one bonus number from the lottery buyer

Closes: #4
# docs: Update feature list

- 사용자의 입력값과 추첨자의 입력값을 서로 비교
  # Compare the user's input values with the lottery buyer's input values
# feat: Compare the user's input values with the lottery buyer's input values

- 사용자의 입력값과 추첨자의 입력값을 서로 비교
  # Compare the user's input values with the lottery buyer's input values

- 결과물 변수에 오름차순으로 정렬하여 결과 담기
  # Store the comparison results in ascending order in the result variable

- 수익률 계산
  # Calculate the profit rate
# feat: Compare the user's input values with the lottery buyer's input values

- test 깨짐 처리
- "구매_금액_테스트()" 복구
> - 개별 테스트는 통과하나, "./gradlew clean test" 명령어 사용 시, ApplicationTest.기능_테스트() 의 동작으로, "8000" + "8000" 되기 때문에,
"16개를 구매했습니다."가 리포트에 나옴.
- 가독성을 위해 코드의 위치를 정리
Copy link

@taeseonYoo taeseonYoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3주차 고생하셨습니다.

우선 서비스 로직이 담당하는 부분의 역할이 모호한 것 같습니다.
서비스단의 역할은 도메인을 가져다 사용하여 조율하는 역할이라고 생각합니다.
서비스 로직이 갖고 있는 필드 값이 많고, 담당하는 역할이 너무 많다고 느꼈습니다.
도메인이 핵심 비즈니스 로직을 갖을 수 있도록 설계하시면 좋을 것 같습니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

객체의 생성과 동시에 메소드를 호출하신 이유가 궁금합니다!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네, 프로그램의 시작점으로 컨트롤러의 메소드를 호출하기 위함이었습니다.

}
}

private void buyLotto() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buyLotto에서 requestInputPrice가 호출되도록 하신 이유가 궁금합니다.
buyLotto 내부에서 requestInputPrice 로직을 동작시키는 게 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제안을 주셔서 감사합니다.
buyLotto 행위에서 추가되는 것들이 있을 경우 메소드들을 더 추가하기 위해서 제작했었습니다.
말씀하신대로 메소드를 호출하는 단계를 줄여도 될 것 같습니다.

/**
* publishedLottoNumbers 초기화
*/
public void clearPublishedLottoNumbers() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트 코드를 위해 작성하신 로직으로 보입니다.

3주차 공통 피드백에 다음과 같은 내용이 있습니다.

테스트를 위한 코드는 구현 코드에서 분리되어야 한다

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와! 감사합니다!!

import lotto.enums.UserInterfaceMessage;

public class LottoPublishService {
private List<Lotto> publishedLottoNumbers = new ArrayList<>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

서비스단에서는 상태를 관리하지 않는 것이 좋다고 생각합니다.

그 예시로, 스프링을 사용하여 앱을 구현하면 LottoPublishService는 기본적으로 싱글톤으로 사용됩니다.

이는 publishedLottoNumbers가 오염될 수 있음을 의미합니다!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다!

publishedLottoNumbers.add(new Lotto(numbers));
}

private Integer String2Integer(String numberformat) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메서드명에 수정이 필요할 것 같습니다.

우선 대문자로 메서드 이름이 시작하고 있습니다. camelCase로 작성하시는 것이 좋을 것 같습니다.

공통 피드백에서는 이름이 길어지더라도 명확하게 표현하도록 하고 있습니다.
convertStringToInteger 은 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

카멜 케이스인데 실수로 대문자가 들어갔군요!
감사합니다.

return earnings;
}

public Map<String, Integer> getMatchResult() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map을 getter로 반환할때는 방어적 복사 기법을 활용해서 불편으로 반환하는 게 좋을 것 같습니다.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다.
"return Collections.unmodifiableMap(new HashMap<>(matchResult));"
"return Map.copyOf(matchResult);"
요런 방식도 있겠군요!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상수말고 enum 타입으로 선택하신 이유가 궁금합니다!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

유지보수 과정에서 게임의 규칙이 바뀔 수도 있는 점과
매직 상수를 사용하지 않고, enum으로 했을 때, 나타나는 단어를 통해서 의도적으로 가독성을 높이고자 했습니다.
한편으로 게임의 규칙이 여러 곳에서 사용될 수 있는 점 또한 고려했습니다.

더 좋은 방법이 있을까요?


private void validate(List<Integer> numbers) {
Set<Integer> lottoNumbers = new HashSet<>(numbers);
if (numbers.size() != LottoRule.LOTTO_MAX_COUNT.getValue()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

입력 숫자가 6개가 아닌 경우, 입력 숫자에 중복된 숫자가 입력되지 않은 경우

이 두 가지를 검증하려고 하시는 것 같습니다.

그렇다면 메서드로 분리해서 하나의 검증 로직이 하나만 검증할 수 있도록 분리하는 것은 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

말씀 감사합니다!
이 케이스에서는 enum에서 사용하는 숫자값을 바로 비교하는 것이 나을 것 같다고 판단했었습니다.
한편으로 이를 묶은 다른 메소드를 두는 것도 좋다고 생각합니다.

}
}

public List<Integer> getNumbers() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에서 설명드린대로 방어적 복사에 대해 알아보시면 좋을 것 같습니다.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다!

this.bonusNumber = bonusNumber;
}

private void validate(Integer number, List<Integer> lottoNumber) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이러한 검증로직도 분리하시면 좋을 것 같습니다.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

두 개의 메소드를 더 추가해서 분리한 로직을 넣으면 되겠군요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants