일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Tags
- break-label
- 테킷
- spring jpa
- GitFlow
- 멋쟁이사자처럼
- querydsl
- PDFBOX
- 값 타입
- Java
- RESPONSEBODY
- Visual Basic
- 프로그래머스
- VB
- Git
- 알고리즘
- 커밋 컨벤션
- 코딩테스트
- 반복문 탈출
- 체인호출
- 스프링부트 쇼핑몰 프로젝트
- responsepart
- PDF병합
- restapi
- 부트캠프
- JPA
- 연관관계
- Hibernate
- 제작기
- springboot
- orm
Archives
- Today
- Total
섭섭한 개발일지
[명언게시판] level 2 본문
구현 요구사항
== 명언 앱 ==
명령) 등록
명언 : 현재를 사랑하라.
작가 : 작자미상
명령) 종료
: 명언게시판 2단계는 명언을 등록하는 기능을 구현하는 것이다.
게시물은 n개를 만들 수 있으므로 게시물을 관리하는 객체를 만들고 배열에 저장하도록 하자.
구현
// main
public class Application {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
List<WiseModel> wiseArr = new ArrayList<>();
while (true) {
System.out.print("명령) ");
String input = sc.nextLine();
if (input.equals("등록")) {
WiseModel wiseModel = new WiseModel();
System.out.print("명언 : ");
String addInput = sc.nextLine();
wiseModel.setSentence(addInput);
System.out.print("작가 : ");
addInput = sc.nextLine();
wiseModel.setAuthor(addInput);
wiseArr.add(wiseModel);
}
if (input.equals("종료")) {
break;
}
}
}
}
// model
public class WiseModel {
String sentence;
String author;
public String getSentence() {
return sentence;
}
public void setSentence(String sentence) {
this.sentence = sentence;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
}
'멋쟁이사자처럼 > Project' 카테고리의 다른 글
[명언게시판] level 6 (0) | 2023.10.27 |
---|---|
[명언게시판] level 5 (0) | 2023.10.27 |
[명언게시판] level 4 (0) | 2023.10.27 |
[명언게시판] level 3 (0) | 2023.10.27 |
[명언게시판] level 1 (0) | 2023.10.27 |
Comments