[자동차 경주] 장민서 미션 제출합니다. - #1447
Open
mingdodev wants to merge 12 commits into
Open
Conversation
- Add list of features to implement. - Add functional requirements.
- Implement method that returns boolean by random. - If value of Random.pickNumberInRange is greater than 4, the method returns true. - Otherwise, it returns false. - Use library to generate random number.
- Implement Car class to manage name, moveCount within single object. - Define a constructor to set default value 0 for moveCount. - Method move() updates moveCount using MoveDecision.byRandom(). - Implement some getter and setter.
- Split user input string to get each car's name. - Create Car object and set name. - Set tryInput to save how many games going to be done. - Throw an IllegalArgumentException when invalid input occurs. - Use enum to manage error messages.
Then separate methods.
Print game progress(try).
Update checklist.
Author
공부할 것
|
ajroot5685
reviewed
Oct 30, 2024
| import java.util.ArrayList; | ||
| import java.util.HashSet; | ||
|
|
||
| public class InputException { |
There was a problem hiding this comment.
InputException이라는 클래스명에서 입력 오류를 처리할 것이라는 기대를 하게 되는데, 입력을 받는 것까지 처리해서 혼동이 올 수 있어보여요
분리하면 좋을 것 같습니다!
Author
There was a problem hiding this comment.
어쩐지 클래스 이름을 지을 때 어떻게 지을지 고민하게 되더라고요 분리해달라고 클래스에서 보내는 신호였구나....!!
이름을 어떻게 바꿀지만 고민했는데 기능 분리가 더 올바른 방법이었네요!!
Comment on lines
+26
to
+31
| HashSet<String> carNameSet = new HashSet<>(); | ||
| for (String s : carInput) { | ||
| if (!carNameSet.add(s)) { | ||
| throw new IllegalArgumentException(ErrorMessage.DUPLICATE_NAME.toString()); | ||
| } | ||
| } |
There was a problem hiding this comment.
저는 중복검사를 매번 데이터가 들어갈 때마다 Stream API의 anyMatch로 검사했는데요!
HashSet이 시간복잡도는 더 낫지만 중복검사용 데이터를 따로 저장해야 한다는 측면에서 두 방식의 장단점이 있는것 같습니다!
Author
There was a problem hiding this comment.
Stream API를 사용하는 방법이 있었네요!
HashSet을 따로 만드는 것이 좀 부자연스럽게 느껴졌는데, 다음에는 anyMatch를 사용해봐야겠어요!
|
|
||
| private static void printProgress(ArrayList<Car> carList) { | ||
| for (Car c : carList) { | ||
| System.out.println(c.getName() + " : " + "-".repeat(c.getMoveCount())); |
Author
There was a problem hiding this comment.
가독성을 높일 수 있는 방법을 계속 고민해봐야겠어요 🥳
매번 꼼꼼히 리뷰해주셔서 감사해요~~~!!
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.