Repository navigation
Expand file tree
/
Copy pathNumber.ava
More file actions
59 lines (37 loc) · 2.44 KB
/
Copy pathNumber.ava
File metadata and controls
59 lines (37 loc) · 2.44 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
//And thus I saw the horses in the vision, and them that sat on them, having breastplates of fire, and of jacinth,
//and brimstone: and the heads of the horses were as the heads of lions; and out of their mouths issued fire and smoke and brimstone. (Revelation 9:17)
package com.javarush.task.task30.task3001;
public class Number {
private NumerationSystem numerationSystem;
private String digit;
public Number(NumerationSystem numerationSystem, String digit) {
this.numerationSystem = numerationSystem;
this.digit = digit;
}
public NumerationSystem getNumerationSystem() {
return numerationSystem;
}
public String getDigit() {
return digit;
}
@Override
public String toString() {
return "Number{" +
"numerationSystem=" + numerationSystem +
", digit='" + digit + '\'' +
'}';
}
}
/*
Конвертер систем счислений
Реализуй логику метода convertNumberToOtherNumerationSystem, который должен переводить число number.getDigit(), из одной системы счисления (numerationSystem) в другую (expectedNumerationSystem).
Брось NumberFormatException, если переданное число некорректно, например, число "120" с системой счисления 2.
Валидация для - number.getDigit() - целое не отрицательное.
Метод main не участвует в тестировании.
Требования:
1. Метод convertNumberToOtherNumerationSystem (Number, NumerationSystem), возвращающий тип Number, должен существовать.
2. Должно бросаться исключение NumberFormatException, если переданное число некорректно в заданной системе счисления.
3. Необходимо корректно реализовать метод convertNumberToOtherNumerationSystem - перевод числа в указанную систему счисления.
4. Enum NumerationSystemType должен поддерживать интерфейс NumerationSystem.
5. В enum-е NumerationSystemType должно присутствовать 11 значений оснований систем счисления. Основания: 2, 3, 4, 5, 6, 7, 8, 9, 10, 12 и 16.
*/