Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.zipcoder.currencyconverterapplication;

import java.util.Arrays;

public enum CurrencyType {
AUSTRALIAN_DOLLAR(2.70),
CANADIAN_DOLLAR(2.64),
Expand All @@ -25,6 +27,12 @@ public Double getRate() {
}

public static CurrencyType getTypeOfCurrency(ConvertableCurrency currency) {
return null;
return Arrays.asList(CurrencyType.values())
.stream()
.filter(currencyType -> currencyType.name().replace("_", "")
.equalsIgnoreCase(currency.getClass().getSimpleName()))
.findAny()
.orElse(null);

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class AustralianDollar implements ConvertableCurrency {
@Override


public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.AUSTRALIAN_DOLLAR.getRate();
return result;
}



}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class CanadianDollar implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.CANADIAN_DOLLAR.getRate();
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class ChineseYR implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.CHINESE_YR.getRate();
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class Euro implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.EURO.getRate();
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class Franc implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.FRANC.getRate();
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class Pound implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.POUND.getRate();
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class Ringgit implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.RINGGIT.getRate();
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class Rupee implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.RUPEE.getRate();
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class SingaporeDollar implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.SINGAPORE_DOLLAR.getRate();
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class USDollar implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.US_DOLLAR.getRate();
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class UniversalCurrency implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.UNIVERSAL_CURRENCY.getRate();
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.zipcoder.currencyconverterapplication.currencies;

import io.zipcoder.currencyconverterapplication.ConvertableCurrency;
import io.zipcoder.currencyconverterapplication.CurrencyType;

public class Yen implements ConvertableCurrency {
public Double convert(CurrencyType currencyType) {
Double result= currencyType.getRate()/CurrencyType.YEN.getRate();
return result;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.