Skip to content

Commit bcee4a9

Browse files
authored
mighty angel come from heaven, clothed with cloud
And I saw another mighty angel come down from heaven, clothed with a cloud: and a rainbow was upon his head, and his face was as it were the sun, and his feet as pillars of fire (Revelation 10:1)
1 parent db9bfb1 commit bcee4a9

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
//And I saw another mighty angel come down from heaven, clothed with a cloud: and a rainbow was upon his head, and his face was as it were the sun, and his feet as pillars of fire (Revelation 10:1)
3+
4+
package com.javarush.task.task30.task3004;
5+
6+
import java.util.concurrent.ForkJoinPool;
7+
8+
/*
9+
Fork/Join
10+
*/
11+
public class Solution {
12+
private String binaryRepresentationMethod(int x) {
13+
int a = x % 2;
14+
int b = x / 2;
15+
String result = String.valueOf(a);
16+
if (b > 0) {
17+
return binaryRepresentationMethod(b) + result;
18+
}
19+
return result;
20+
}
21+
22+
23+
public static void main(String[] args) {
24+
Solution solution = new Solution();
25+
String result1 = solution.binaryRepresentationMethod(6);
26+
System.out.println(result1);
27+
28+
System.out.println();
29+
ForkJoinPool forkJoinPool = new ForkJoinPool();
30+
String result2 = forkJoinPool.invoke(new BinaryRepresentationTask(6));
31+
System.out.println(result2);
32+
}
33+
34+
}
35+
36+
/*
37+
Fork/Join
38+
39+
1. Создай класс BinaryRepresentationTask. Для этого в IntelliJ IDEA на красном имени класса нажми Alt+Enter -> Create Class ...
40+
41+
(класс должен наследоваться от RecursiveTask<String>). Параметр конструктора - int x.
42+
43+
2. Реализуй логику метода compute - число должно переводиться в двоичное представление.
44+
45+
3. Используй методы fork и join.
46+
47+
4. Пример функциональной реализации - метод binaryRepresentationMethod.
48+
49+
50+
51+
52+
53+
Требования:
54+
55+
1. Создай класс BinaryRepresentationTask.
56+
57+
2. В классе BinaryRepresentationTask должен быть переопределен метод compute().
58+
59+
3. В классе BinaryRepresentationTask в методе compute() используй методы fork() и join().
60+
61+
4. Метод compute() должен правильно переводить число в двоичную систему счисления.
62+
*/

0 commit comments

Comments
 (0)