Skip to content

Conversation

@lylylylh
Copy link

No description provided.

Copy link

@JangIkhwan JangIkhwan left a comment

Choose a reason for hiding this comment

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

확인이 늦었네요. 고생 많으셨습니다.

Comment on lines +8 to +15
public void drawLine(Position pos, int direction) {
if(direction == -1){
drawLineToLeft(pos);
}
if(direction == 1){
drawLineToRight(pos);
}
}

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을 사용해볼 수 있을 것 같아요.

Comment on lines +5 to +6
public Ladder(int height, int numberOfPerson) {
positions = new int[height][numberOfPerson];

Choose a reason for hiding this comment

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

height, numberOfPerson에 음수 값이 들어가면 문제가 생길 수 있지 않을까요..? 어떻게 하면 이 문제를 객체지향적으로 해결할 수 있지 고민해봅시다.

Comment on lines +8 to +13
@Test
void Ladder_init() {
int height = 5, numberOfPerson = 5;
Ladder ladder = new Ladder(height, numberOfPerson);
assertThat(ladder).isNotNull();
}
Copy link

@JangIkhwan JangIkhwan Sep 21, 2024

Choose a reason for hiding this comment

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

given-when-then 패턴대로 주석을 달아놓으면 테스트를 이해하기 편할 것 같아요

Comment on lines +62 to +73
@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);
}

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
}

Choose a reason for hiding this comment

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

이 테스트에서도 마찬가지로 assertThatThrownBy()를 이용해보세요

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