@@ -9,13 +9,23 @@ public class ChannelMenu {
9
9
private final ChannelService channelService ;
10
10
private Channel currentChannel ;
11
11
12
- public ChannelMenu (Scanner scanner , ChannelService channelService , Channel currentChannel ) {
12
+ public ChannelMenu (Scanner scanner , ChannelService channelService ) {
13
13
this .sc = scanner ;
14
14
this .channelService = channelService ;
15
- this .currentChannel = currentChannel ;
16
15
}
17
16
18
17
public void run () {
18
+
19
+ System .out .println ("모든 채널 정보를 출력합니다." );
20
+ channelService .outputAllChannelInfo ();
21
+ System .out .println ("들어가실 채널 번호를 선택해 주세요." );
22
+ int channelNumber = Integer .parseInt (sc .nextLine ());
23
+ currentChannel = channelService .getChannelByNumber (channelNumber );
24
+ if (currentChannel == null ) {
25
+ System .out .println ("유효하지 않은 채널 번호입니다." );
26
+ return ;
27
+ }
28
+
19
29
while (true ) {
20
30
System .out .println ("1. 채널 생성\t 2. 현재 채널 정보 출력\t 3. 모든 채널 정보 출력\t 4. 채널 이름 수정\t 5. 채널 삭제\t 6. 채널 변경\t 7. 이전 메뉴" );
21
31
int n = Integer .parseInt (sc .nextLine ());
@@ -29,24 +39,19 @@ public void run() {
29
39
case 2 -> channelService .outputOneChannelInfo (currentChannel );
30
40
case 3 -> channelService .outputAllChannelInfo ();
31
41
case 4 -> {
32
- if (currentChannel != null ) {
33
- System .out .println (
34
- "현재 접속중인 채널은 " + currentChannel .getChannelName () + "입니다. 새로운 채널 이름을 입력해 주세요." );
35
- String updateChannelName = sc .nextLine ();
36
- channelService .updateChannelName (currentChannel , updateChannelName );
37
- }
42
+ System .out .println ("현재 접속중인 채널은 " + currentChannel .getChannelName () + "입니다. 새로운 채널 이름을 입력해 주세요." );
43
+ String updateChannelName = sc .nextLine ();
44
+ channelService .updateChannelName (currentChannel , updateChannelName );
38
45
}
39
46
case 5 -> {
40
- if (currentChannel != null ) {
41
- System .out .println (currentChannel .getChannelName () + " 채널을 삭제합니다." );
42
- channelService .deleteChannelName (currentChannel );
43
- System .out .println ("정상적으로 채널이 삭제됐습니다. 변경하실 채널 번호를 입력해주세요." );
44
- channelService .outputAllChannelInfo ();
45
- int newChannelNumber = Integer .parseInt (sc .nextLine ());
46
- currentChannel = channelService .getChannelByNumber (newChannelNumber );
47
- if (currentChannel == null ) {
48
- System .out .println ("유효하지 않은 채널 번호입니다." );
49
- }
47
+ System .out .println (currentChannel .getChannelName () + " 채널을 삭제합니다." );
48
+ channelService .deleteChannelName (currentChannel );
49
+ System .out .println ("정상적으로 채널이 삭제됐습니다. 변경하실 채널 번호를 입력해주세요." );
50
+ channelService .outputAllChannelInfo ();
51
+ int newChannelNumber = Integer .parseInt (sc .nextLine ());
52
+ currentChannel = channelService .getChannelByNumber (newChannelNumber );
53
+ if (currentChannel == null ) {
54
+ System .out .println ("유효하지 않은 채널 번호입니다." );
50
55
}
51
56
}
52
57
case 6 -> {
@@ -65,4 +70,4 @@ public void run() {
65
70
}
66
71
}
67
72
}
68
- }
73
+ }
0 commit comments