요구사항
종료 입력시 종료
- 등록 입력시 명언 등록
- 등록시 생성된 명언 번호 출력
- 등록할 때마다 명언번호 증가
- 목록 입력시 현재까지 생성된 명언 목록 출력
- 명언번호로 명언 삭제
- 존재하지 않는 번호로 삭제 시도시 예외 처리
- 명언 수정
- 파일을 통한 영속성
- json 파일 빌드
Code
class App {
void run() {
System.out.println("== 명언 앱 ==");
while (true) {
System.out.print("명언) ");
Scanner sc = new Scanner(System.in);
String cmd = sc.nextLine();
if (cmd.equals("종료")) {
break;
} else if (cmd.equals("등록")) {
System.out.print("명언 : ");
String content = sc.nextLine();
System.out.print("작가 : ");
String author = sc.nextLine();
System.out.println("1번 명언이 등록되었습니다.");
}
}
}
}
실행 결과