-
Notifications
You must be signed in to change notification settings - Fork 0
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
2주차 심화과제 #3
base: #2
Are you sure you want to change the base?
2주차 심화과제 #3
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.
수현님 고생하셨어요!!!!👍👍
if (postId < postList.size()) { | ||
Post updatePost = new Post( | ||
post.getWriter(), | ||
post.getTitle(), | ||
post.getContent(), | ||
postList.get(postId).getLike() | ||
); |
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.
if문 조건에서 아직 DB 구현이 되지 않아서 postId < postList.size()일 때만 수정이 가능하게 코드를 작성해주신걸까요?!
해당 로직에선 postId를 다른 postId로 잘못 입력해도 수정이 가능할 것 같아서요!
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.
아마 if문으로 postId가 postList의 사이즈보다 작아야 해당 포스트가 존재해서 예외처리 해 주신 것 같아요!!
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.
맞습니다! list 크기를 초과하는 postId가 들어오면 존재하지 않는 게시물이기 때문에 if문을 써줬어요!
if (postId < postList.size()) { | ||
postList.remove(postId); | ||
return Optional.of(postId); |
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.
여기도 위와 마찬가지로 이렇게 if문을 작성해주신 이유가 궁금합니다!!
if (postId < postList.size()) { | ||
Post updatePost = new Post( | ||
post.getWriter(), | ||
post.getTitle(), | ||
post.getContent(), | ||
postList.get(postId).getLike() | ||
); |
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.
아마 if문으로 postId가 postList의 사이즈보다 작아야 해당 포스트가 존재해서 예외처리 해 주신 것 같아요!!
postList.set(postId, updatePost); | ||
return Optional.of(postList.get(postId).toString()); | ||
} | ||
return Optional.empty(); |
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.
Optional.of와 Optional.empty 제가 처음 보는 메서드인데 뭔가 예외처리를 해줄 수 있는 애들 같아서 기능 찾아보고 저도 나중에 예외처리 할 때 사용해보겠습니다ㅎㅎ 예외처리 하는 방법 하나 배워갑니다!!
✅ 과제 구현 명세
[심화과제]
결과 화면
😊 이런 점이 새로웠어요 / 어려웠어요