-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurrency.java
More file actions
37 lines (30 loc) · 867 Bytes
/
Currency.java
File metadata and controls
37 lines (30 loc) · 867 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
package chapter2;
/**
* Created by Elev1 on 2016-05-30.
*/
public enum Currency {
DOLLAR("$","USA"),
POUND("£","UK"),
EURO("€","France,Germany"),
KRONA("SEK","Sweden");
private String symbol;
private String country;
private Currency(String symbol,String country) {
this.symbol = symbol;
this.country = country;
}
public static String getCountryFromSymbol(String symbols){
String country = "";
for (Currency s : values() ) {
if (s.symbol.equals(symbols))
country = s.country;
}
return country;
}
public static void main(String[] args) {
System.out.println(Currency.DOLLAR.country);
System.out.println(Currency.DOLLAR.symbol);
System.out.println(Currency.getCountryFromSymbol("SEK"));
// Currency.
}
}