Java/Java log

2020-11-09 Java log - 게시판 기능 추가

qbj700 2020. 11. 9. 13:24

- makeBoard 를 통하여 게시판 생성

- selectBoard 를 통하여 게시판 선택

- currentBoard 를 통하여 현재 선택된 게시판이 무엇인지 확인

 

https://github.com/qbj700/easy-text-board

 

qbj700/easy-text-board

Contribute to qbj700/easy-text-board development by creating an account on GitHub.

github.com

그외 2020-11-09 수정사항 github

 

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
private void currentBoard(String command) {
        if (Container.session.selectedBoardId == 0) {
            System.out.println("게시판 선택 후 이용해 주세요.");
            return;
        }
 
        Board board = articleService.getBoardById(Container.session.selectedBoardId);
        System.out.printf("현재 \"%s\" 게시판이 선택되어있는 상태입니다.\n", board.name);
 
    }
 
    private void selectBoard(String command) {
        int inputedId = 0;
 
        try {
            inputedId = Integer.parseInt(command.split(" ")[2]);
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("입력된 값이 존재하지 않습니다.");
            return;
        } catch (NumberFormatException e) {
            System.out.println("게시판 번호는 양의 정수를 입력해주세요.");
            return;
        }
 
        Board board = articleService.getBoardById(inputedId);
 
        if (board == null) {
            System.out.printf("%d번 게시판은 존재하지 않습니다.\n", inputedId);
            return;
        }
        System.out.printf("%s(%d번) 게시판이 선택되었습니다.\n", board.name, board.id);
        Container.session.selectedBoard(board.id);
 
    }
 
    private void makeBoard(String command) {
        if (Container.session.isLogout()) {
            System.out.println("로그인 후 이용해주세요");
            return;
        }
        System.out.println("== 게시판 생성 ==");
 
        System.out.printf("게시판 이름 : ");
        String boardName = Container.scanner.nextLine();
 
        int boardId = articleService.makeBoard(boardName);
        System.out.printf("%s(%d번) 게시판이 생성되었습니다.\n", boardName, boardId);
 
    }
cs
반응형