forked from next-step/java-coordinate-playground
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInputView.java
More file actions
33 lines (27 loc) · 961 Bytes
/
InputView.java
File metadata and controls
33 lines (27 loc) · 961 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 coordinate.Point;
import coordinate.Points;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
public class InputView {
private final static Scanner scanner = new Scanner(System.in);
public Points inputPoint(){
System.out.println("좌표를 입력하세요.");
String s = scanner.next();
Points points = new Points();
String[] strings = s.split("-");
for(String str: strings){
List<Integer> numbers = new ArrayList<>();
List<String> nums = Arrays.stream(str.split("\\(|,|\\)")).filter(t -> !t.isEmpty()).collect(Collectors.toList());
for(String n: nums){
numbers.add(Integer.valueOf(n));
}
Point point = Point.of(numbers.get(0), numbers.get(1));
points.addPoint(point);
}
return points;
}
}