Skip to content
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

[step4] πŸš€ 4단계 - μžλ™μ°¨ κ²½μ£Ό(우승자) #5477

Open
wants to merge 2 commits into
base: shgpwn
Choose a base branch
from

Conversation

shgpwn
Copy link

@shgpwn shgpwn commented Mar 17, 2024

졜초 κ΅¬ν˜„

Copy link

@wheejuni wheejuni left a comment

Choose a reason for hiding this comment

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

μ „λ°˜μ μœΌλ‘œ 큰 고민이 없이 λ―Έμ…˜ 진행 및 μ½”λ“œ μž‘μ„±μ΄ 이뀄진 것 κ°™μ•„, λ¦¬λ·°μ–΄λ‘œμ„œ 아쉬움이 μ§„ν•˜κ²Œ λ‚¨λŠ” PRμž…λ‹ˆλ‹€.
λ¬Όλ‘  μƒμ†Œν•œ 과제λ₯Ό μ ‘ν•˜κ³  닡을 μ°Ύμ•„κ°€λŠ” 과정이 늘 즐거울 순 μ—†κ² μ§€λ§Œ, 쑰금 더 μΉ˜μ—΄ν•œ κ³ λ―Όκ³Ό, κΉŠμ΄μžˆλŠ” 섀계λ₯Ό κΈ°λŒ€ν•©λ‹ˆλ‹€. κ·Έλ™μ•ˆ ν•΄μ˜€μ…¨λ˜ λ°©μ‹μœΌλ‘œ λ˜‘κ°™μ΄ μ½”λ“œλ₯Ό μž‘μ„±ν•˜μ‹€ 것이라면, 우리 과정에 μ°Έμ—¬ν•˜μ‹œλŠ” 의미λ₯Ό 살리기 μ–΄λ ΅λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.
μ œκ°€ μš”λŸ° 생각을 κ°–κ²Œλœ 근거듀을 ν•˜λ‚˜μ”© μ‚΄νŽ΄ λ“œλ¦¬κ² μŠ΅λ‹ˆλ‹€.

  1. ν…ŒμŠ€νŠΈκ°€ λ„ˆλ¬΄ λΉˆμ•½ν•©λ‹ˆλ‹€. κ³Όν•œ ν…ŒμŠ€νŠΈλ„ λ¬Έμ œμ§€λ§Œ, 전체적인 μ½”λ“œ 변경에 λΉ„ν•΄ ν…ŒμŠ€νŠΈ μ½”λ“œκ°€ λ„ˆλ¬΄ 적게 μΆ”κ°€λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
  2. for loop μ‚¬μš© λ“± μƒˆλ‘œμš΄ μ‹œλ„λ³΄λ‹€λŠ” 기쑴에 ν”„λ‘œκ·Έλž˜λ°μ„ μ§„ν–‰ν•˜μ…¨λ˜ λ°©λ²•λŒ€λ‘œ μ§„ν–‰ν•˜μ‹  것 κ°™μŠ΅λ‹ˆλ‹€.
  3. κ°•μ˜ μžλ£Œλ‚˜ 라이브 κ°•μ˜ 등을 ν†΅ν•΄μ„œ κ°œμ„  포인트라고 μ „λ‹¬λ˜μ—ˆλ˜ 뢀뢄듀이 λ°˜μ˜λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.
  4. μ ‘κ·Ό μ œμ–΄μž λˆ„λ½ λ“±, 기본적으둜 μ§€μΌœμ£Όμ‹œλ©΄ 쒋을 λ²•ν•œ λ‚΄μš©λ“€μ„ 챙겨주지 μ•ŠμœΌμ…¨μŠ΅λ‹ˆλ‹€.

λ”°λΌμ„œ μ•„λž˜μ™€ 같은 μ•‘μ…˜ 포인트 μž‘μ•„ λ“œλ¦¬κ² μŠ΅λ‹ˆλ‹€.

  1. for loop을 톡해 객체 μƒνƒœ λ³€κ²½ν•˜λŠ” λ‘œμ§μ€ λͺ¨λ‘ stream API의 μ‚¬μš©μœΌλ‘œ κ°œμ„ ν•΄ λ³΄μ„Έμš”.
  2. μ ‘κ·Ό μ œμ–΄μžκ°€ λˆ„λ½λœ 뢀뢄에 λŒ€ν•΄μ„  package-private을 μ˜λ„ν•˜μ‹œλŠ” 게 μ•„λ‹ˆλΌλ©΄ λͺ¨λ‘ μ ‘κ·Ό μ œμ–΄μžλ₯Ό λΆ™μ—¬ μ£Όμ‹œκΈ° λ°”λžλ‹ˆλ‹€.
  3. ν•˜λ‚˜μ˜ ν΄λž˜μŠ€μ— λŒ€ν•΄ ν•˜λ‚˜μ˜ ν…ŒμŠ€νŠΈ 클래슀λ₯Ό 무쑰건 두고, ν…ŒμŠ€νŠΈ μΌ€μ΄μŠ€ μ΅œλŒ€ν•œ λ„μΆœν•΄ μ£Όμ‹œλ©΄ μ’‹κ² μŠ΅λ‹ˆλ‹€.

쑰금 더 λ‚˜μ€ μ½”λ“œλ₯Ό κΈ°λŒ€ν•΄ λ³΄κ² μŠ΅λ‹ˆλ‹€. κ°μ‚¬ν•©λ‹ˆλ‹€ πŸ‘

private static final String HYPHEN = "-";
private static final String SPACE = " ";
private static final String COLON = ":";
int currentPosition;

Choose a reason for hiding this comment

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

μš”κΈ°μ—λ„ μ ‘κ·Ό μ œμ–΄μžκ°€ λΆ™μ–΄μ•Ό ν•  것 κ°™μŠ΅λ‹ˆλ‹€. ν•˜λ‚˜ λΆ™μ—¬μ£Όμ‹œμ£ !

Comment on lines +11 to +17
InputView inputView;
ResultView resultView;

List<Car> carList;
String[] carNameList;
int roundCount;
Random random;

Choose a reason for hiding this comment

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

  1. μ ‘κ·Ό μ œμ–΄μž λˆ„λ½λ˜λ©΄ μ•ˆλ©λ‹ˆλ‹€. κΌ­ μ±™κ²¨μ£Όμ„Έμš”
  2. μ§€κΈˆ μ»¨νŠΈλ‘€λŸ¬μ—μ„œ λ‹€ κ΄€λ¦¬ν•˜κ³  μžˆλŠ” μš” λ³€μˆ˜λ“€μ„ 챙겨쀄 RacingGame μ΄λΌλŠ” 클래슀λ₯Ό μ„€κ³„ν•˜κ³  μž‘μ„±ν•΄λ³΄μ„Έμš”. 이 클래슀의 κΈ°λŠ₯은 λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.
  • Inputview λ‘œλΆ€ν„° ν”Œλ ˆμ΄μ–΄ 이름 μž…λ ₯λ°›μŒ
  • λͺ‡ 번 λŒλ¦΄κ±΄μ§€ 회차 μž…λ ₯λ°›μŒ
  • μ‹€μ œ κ²Œμž„ μˆ˜ν–‰
  • νšŒμ°¨λ³„ κ²°κ³Ό 관리

Comment on lines +68 to +71
for (Car car : carList) {
String stringCurrentPosition = car.makeStringCurrentPosition();
resultRound += stringCurrentPosition + "\n";
}

Choose a reason for hiding this comment

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

stream API 둜 κ°œμ„ ν•  수 μžˆμŠ΅λ‹ˆλ‹€. κ°œμ„  μ‹œλ„ν•΄λ³΄μ„Έμš”.


import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

public class RacingCarWinnerTest {

Choose a reason for hiding this comment

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

ν…ŒμŠ€νŠΈμ˜ ꡬ성에 μžˆμ–΄μ„œ λͺ‡ 가지 ν΄λž˜μŠ€λ“€μ— λŒ€ν•œ ν…ŒμŠ€νŠΈκ°€ ν•œ ν…ŒμŠ€νŠΈ 클래슀 파일둜 합쳐져 μžˆλŠ”λ°μš”, μš”κ±΄ 일단...

  1. ν…ŒμŠ€νŠΈ λ¨Όμ € μž‘μ„±ν•˜μ‹œκ³  κ΅¬ν˜„ν•˜λŠ” 흐름을 κ°€μ Έκ°€κ³  κ³„μ‹œμ§€ μ•Šλ‹€λŠ” κ±Έ μ•Œ 수 μžˆμŠ΅λ‹ˆλ‹€.
  2. 이 자체둜 μ½”λ“œ μŠ€λ©œμž…λ‹ˆλ‹€. ν…ŒμŠ€νŠΈλŠ” λ©”μ†Œλ“œ λ‹¨μœ„ 싀행이 μ•„λ‹Œ 클래슀 λ‹¨μœ„ 싀행이면 μ’‹κ² κ³ , 각 ν΄λž˜μŠ€κ°€ μ˜λ―Έλ‹¨μœ„λ₯Ό κ°€μ‘ŒμœΌλ©΄ ν•©λ‹ˆλ‹€.

import java.util.Scanner;

public class InputView {
private Scanner scanner = new Scanner(System.in);

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.

@wheejuni λ¦¬λ·°μ–΄λ‹˜ μ™ΈλΆ€μ—μ„œ μ£Όμž…λ°›λŠ” 방식이 무슨 μ˜λ―ΈμΌκΉŒμš”??
InputViewμ—μ„œλŠ” μž…λ ₯κ°’λ§Œ λ°›κ³ , split 같은 μž…λ ₯ 값에 λŒ€ν•œ λ‘œμ§μ€ μ™ΈλΆμ—μ„œ μ²˜λ¦¬ν•˜λŠ” 방식을 λ§μ”€ν•˜μ‹  κ±ΈκΉŒμš”??
μ œκ°€ μ΄ν•΄ν•œ 게 λ§žλŠ”μ§€ κΆκΈˆν•˜μ—¬ 확인차 μ—¬μ­ˆμ–΄ λ΄…λ‹ˆλ‹€^^

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