-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathInputView.java
More file actions
33 lines (28 loc) · 994 Bytes
/
InputView.java
File metadata and controls
33 lines (28 loc) · 994 Bytes
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
package view;
import java.util.*;
public class InputView {
private static Scanner scanner = new Scanner(System.in);
//차이름 입력 메소드
public static Map<String, Integer> readCarNames(){
try{
Map<String, Integer> cars = new HashMap<>();
System.out.println("경주할 자동차 이름을 입력하세요(이름은 쉼표(,)를 기준으로 구분).");
String line = scanner.nextLine();
String[] str = line.split(",");
for(int i = 0; i<str.length; i++){
cars.put(str[i], 1);
}
return cars;
}catch(IllegalArgumentException e){
System.out.println(e.getMessage());
return null;
}
}
//시도횟수 입력 메소드
public static int readTryCount(){
System.out.println("시도할 횟수는 몇회인가요?");
int count = scanner.nextInt();
scanner.nextLine();
return count;
}
}