-
Notifications
You must be signed in to change notification settings - Fork 26
1주차 미션 / 서버 3조 이윤희 #28
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
base: main
Are you sure you want to change the base?
Conversation
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.
확인이 늦었네요. 고생 많으셨습니다.
| public void drawLine(Position pos, int direction) { | ||
| if(direction == -1){ | ||
| drawLineToLeft(pos); | ||
| } | ||
| if(direction == 1){ | ||
| drawLineToRight(pos); | ||
| } | ||
| } |
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.
방향을 지정할 수 있도록 기능을 구현한 점 좋은 것 같아요. 그런데 direction이 무조건 -1 또는 1 중 하나의 값을 가져야 제대로 선을 그을텐데, 그외의 값을 가지면 선을 긋지 못할 우려가 있네요. direction이 가지는 값을 한정하기 위해서 enum을 사용해볼 수 있을 것 같아요.
| public Ladder(int height, int numberOfPerson) { | ||
| positions = new int[height][numberOfPerson]; |
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.
height, numberOfPerson에 음수 값이 들어가면 문제가 생길 수 있지 않을까요..? 어떻게 하면 이 문제를 객체지향적으로 해결할 수 있지 고민해봅시다.
| @Test | ||
| void Ladder_init() { | ||
| int height = 5, numberOfPerson = 5; | ||
| Ladder ladder = new Ladder(height, numberOfPerson); | ||
| assertThat(ladder).isNotNull(); | ||
| } |
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.
given-when-then 패턴대로 주석을 달아놓으면 테스트를 이해하기 편할 것 같아요
| @Test | ||
| void IndexExceptionCode(){ | ||
| // => Test Fail : Index Error | ||
| int height = 5, numberOfPerson = 3; | ||
| Ladder ladder = new Ladder(height, numberOfPerson); | ||
| ladder.drawLine(new Position(0, 0), 1); | ||
| ladder.drawLine(new Position(1, 1), 1); | ||
| ladder.drawLine(new Position(2, 2), 1); | ||
|
|
||
| int result = ladder.run(0); | ||
| assertThat(result).isEqualTo(1); | ||
| } |
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.
테스트코드는 모두 통과되어야 합니다. 예외가 의도대로 발생하는지를 체크하려면 assertThatThrownBy()를 이용해보세요
|
|
||
| int result = ladder.run(3); // 2 | ||
| assertThat(result).isEqualTo(0); // 1 | ||
| } |
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.
이 테스트에서도 마찬가지로 assertThatThrownBy()를 이용해보세요
No description provided.