diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 0c770d7..3b47b18 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,6 +1,23 @@ +import java.util.Scanner; + public class Main { public static void main(String[] args) { EcbApi getRates = new EcbApi(); - System.out.println(getRates.exchangeRate("PLN")); + + String continuteInput; + Scanner read = new Scanner(System.in); + + while(true) { + System.out.print("Podaj trzyliterowy kod waluty: "); + String currencyCode = read.nextLine(); + + System.out.println("Kurs EUR/" + currencyCode + " wynosi " + getRates.exchangeRate(currencyCode)); + + System.out.print("Czy chcesz sprawdzić kurs kolejnej waluty? [t/n] "); + continuteInput = read.nextLine(); + if(continuteInput.equals("n")) { + break; + } + } } } diff --git a/src/main/java/RatesProcessing.java b/src/main/java/RatesProcessing.java index 6f0b55d..2affb54 100644 --- a/src/main/java/RatesProcessing.java +++ b/src/main/java/RatesProcessing.java @@ -30,6 +30,11 @@ public class RatesProcessing { } public BigDecimal getRate(String currencyCode) { - return rates.get(currencyCode); + if(rates.containsKey(currencyCode)) { + return rates.get(currencyCode); + } + else { + return BigDecimal.valueOf(0); + } } }