private void modify(int inputedId, String title, String body) {
Article article = getArticle(inputedId);
article.title = title;
article.body = body;
}
else if (command.startsWith("article modify")) {
String[] commandBits = command.split(" ");
System.out.println("* 게시글 수정 *");
if (commandBits.length <= 2) {
System.out.println("수정하고 싶은 게시물 번호와 함께 입력해 주세요.");
continue;
}
int inputedId = Integer.parseInt(commandBits[2]);
Article article = getArticle(inputedId);
if (article == null || article.id == 0) {
System.out.printf("%d번째 게시글은 존재하지 않습니다.\n", inputedId);
continue;
}
System.out.printf("%d번째) 제목 :", article.id);
String title = sc.nextLine();
System.out.printf("내용 : ");
String body = sc.nextLine();
modify(inputedId, title, body);
System.out.printf("%d번 게시물이 수정되었습니다.\n", inputedId);
}
*전체적인 일상은 노션을 통해 작성하고 있습니다.
링크 : www.notion.so/009-f23b45eedb564f05a30c9d4e4df1cca7
'Java' 카테고리의 다른 글
#031 객체 자동 생성 ! (0) | 2020.12.10 |
---|---|
#030 add함수 추가 및 delete 기능 구현 (0) | 2020.12.09 |
#028 리스팅 역순 코드 (0) | 2020.12.09 |
#027 Article 리모콘 저장 공간의 개념 정리 (0) | 2020.12.09 |
#026 index / add 개념 및 예시 (0) | 2020.12.09 |