-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.java
More file actions
36 lines (29 loc) · 1.07 KB
/
main.java
File metadata and controls
36 lines (29 loc) · 1.07 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
import java.util.ArrayList;
import java.util.Collections;
/**
* Created by ignacioojanguren on 27/10/16.
*
* This class sorts the Kings with roman's numbers by their names.
* In case two or more kings have the same name, the Kings will be sorted by the value of the roman number.
*/
public class main {
public static void main(String[] args){
ArrayList <King> orderKings = new ArrayList<King>();
King philipII = new King("Philip", "II");
King charlesI = new King("Charles", "I");
King alfonsoXIII = new King("Alfonso", "XIII");
King fernandoXIV = new King("Fernando", "XIV");
King fernandoXXIV = new King("Fernando", "XXIV");
King philipIV = new King("Philip", "IV");
orderKings.add(philipII);
orderKings.add(charlesI);
orderKings.add(alfonsoXIII);
orderKings.add(fernandoXIV);
orderKings.add(fernandoXXIV);
orderKings.add(philipIV);
Collections.sort(orderKings);
for(King king: orderKings){
System.out.println(king.toString());
}
}
}