Created
May 1, 2021 16:57
-
-
Save balsikandar/56ceb6f33aa9b2a7a336151fd24ddc78 to your computer and use it in GitHub Desktop.
This Gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Currency { | |
val map = HashMap<String, String>(); | |
init { | |
map.put("India", "Rupee") | |
map.put("UK", "Euro") | |
map.put("Japan", "Yen") | |
map.put("USA", "Dollar") | |
map.put("China", "Yuan") | |
} | |
fun getCurrencyNameOf(country: String): String { | |
return map.get(country) ?: "NA" | |
} | |
} | |
// Call getCurrencyOf from anywhere now by passing string | |
fun main() { | |
val currency = Currency() | |
val indianCurrency = currency.getCurrencyNameOf("India") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment