-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathRomanNumber.java
More file actions
48 lines (40 loc) · 887 Bytes
/
RomanNumber.java
File metadata and controls
48 lines (40 loc) · 887 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* 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(String l) {
for (RomanNumber r : RomanNumber.values()) {
if (r.toString().equals(l)) {
return r.value;
}
}
throw new IllegalArgumentException("Not a romand symbol!");
}
}