-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathRomanNumber.java
More file actions
58 lines (52 loc) · 1.14 KB
/
RomanNumber.java
File metadata and controls
58 lines (52 loc) · 1.14 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package romannumberconversion;
/**
*
* @author roberta
*/
public enum RomanNumber {
I(1),
V(5),
X(10),
L(50),
C(100),
D(500),
M(1000);
private final int value;
RomanNumber(int value) {
this.value = value;
}
public int getValue() {
return this.value;
}
/**
* Devuelve el valor numérico de la letra romana
*
* @param l
* @return
*/
public static int parse(char l) {
switch (l) {
case 'I':
return I.value;
case 'V':
return V.value;
case 'X':
return X.value;
case 'L':
return L.value;
case 'C':
return C.value;
case 'D':
return D.value;
case 'M':
return M.value;
default:
throw new IllegalArgumentException("Not a romand symbol!");
}
}
}