Main

 package ex1;
import java.sql.SQLException;
import com.lec.app.console.NoticeConsole;

public class program5 {

	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		NoticeConsole console = new NoticeConsole();
		console.printNoticeList();
		int menu =console.inputNoticeMenu();
		
		switch(menu) {
		case 1: //상세 조회
			break;
		case 2:  //이전
			break;
		case 3: // 다음
			break;
		case 4: //글쓰기
			break;
			
		}
	}
}

NoticeConsole


import java.sql.SQLException;
import java.util.List;
import com.lec.app.entity.Notice;
import com.lec.app.service.NoticeService;

public class NoticeConsole {
	
	private NoticeService service;
	
	public NoticeConsole() {
		service = new NoticeService();
	}
	

	public void printNoticeList() throws ClassNotFoundException, SQLException {
		List<Notice> list = service.getList();
		
		System.out.println("────────────────────");
		System.out.printf("<공지사항> 총 %d 게시글\n",12); 
		System.out.println("────────────────────");
		
		for(Notice n:list) {
		System.out.printf("%d. %s / %s / %s\n",
											n.getId(), n.getTitle(), n.getWirterid(),n.getRegDate());
		}
		System.out.println("────────────────────");
		System.out.printf("                %d/%d  pages\n",1,2); 

	}

	public int inputNoticeMenu() {
		return 0;
	}
	

}

일단 출력되는 부분만 구현했다.

구현

댓글남기기