-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path[PCCP 기출문제] 1번 / 동영상 재생기.java
More file actions
60 lines (52 loc) · 1.7 KB
/
[PCCP 기출문제] 1번 / 동영상 재생기.java
File metadata and controls
60 lines (52 loc) · 1.7 KB
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
50
51
52
53
54
55
56
57
58
59
60
class Solution {
public String solution(String video_len, String pos, String op_start, String op_end, String[] commands) {
StringBuilder answer = new StringBuilder();
int v = Integer.parseInt(video_len.split(":")[0])*60 + Integer.parseInt(video_len.split(":")[1]);
int p = Integer.parseInt(pos.split(":")[0])*60 + Integer.parseInt(pos.split(":")[1]);
int ops = Integer.parseInt(op_start.split(":")[0])*60 + Integer.parseInt(op_start.split(":")[1]);
int ope = Integer.parseInt(op_end.split(":")[0])*60 + Integer.parseInt(op_end.split(":")[1]);
for (String command : commands) {
if (p >= ops && p <= ope) {
p = skipOpenning(p, ops, ope);
}
if (command.equals("next")) {
p = moveNext(p, v);
} else if (command.equals("prev")) {
p = movePrev(p);
}
if (p >= ops && p <= ope) {
p = skipOpenning(p, ops, ope);
}
}
int m = p / 60;
int s = p % 60;
return String.format("%02d:%02d", m, s);
}
/*
오프닝 건너뛰기
*/
static int skipOpenning(int time, int ops, int ope) {
if (time >= ops && time <= ope) {
return ope;
}
return time;
}
/*
10초 전으로 이동
*/
static int movePrev(int time) {
if (time - 10 < 0) {
return 0;
}
return time - 10;
}
/*
10초 뒤로 이동
*/
static int moveNext(int time, int v) {
if (time + 10 > v) {
return v;
}
return time + 10;
}
}