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,7 +1,10 @@
package io.zipcoder.currencyconverterapplication;

public interface ConvertableCurrency {

default Double convert(CurrencyType currencyType) {
return Double.MAX_VALUE;
return currencyType.getRate() / this.getRate();
}

Double getRate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,42 @@ public Double getRate() {
}

public static CurrencyType getTypeOfCurrency(ConvertableCurrency currency) {
if (currency.getRate() == AUSTRALIAN_DOLLAR.rate) {
return AUSTRALIAN_DOLLAR;
}
else if (currency.getRate() == CANADIAN_DOLLAR.rate) {
return CANADIAN_DOLLAR;
}
else if (currency.getRate() == CHINESE_YR.rate) {
return CHINESE_YR;
}
else if (currency.getRate() == EURO.rate) {
return EURO;
}
else if (currency.getRate() == FRANC.rate) {
return FRANC;
}
else if (currency.getRate() == POUND.rate) {
return POUND;
}
else if (currency.getRate() == RINGGIT.rate) {
return RINGGIT;
}
else if (currency.getRate() == RUPEE.rate) {
return RUPEE;
}
else if (currency.getRate() == SINGAPORE_DOLLAR.rate) {
return SINGAPORE_DOLLAR;
}
else if (currency.getRate() == US_DOLLAR.rate) {
return US_DOLLAR;
}
else if (currency.getRate() == UNIVERSAL_CURRENCY.rate) {
return UNIVERSAL_CURRENCY;
}
else if (currency.getRate() == YEN.rate) {
return YEN;
}
return null;
}
}
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 AustralianDollar implements ConvertableCurrency {
@Override
public Double getRate() {
return CurrencyType.AUSTRALIAN_DOLLAR.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.CANADIAN_DOLLAR.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.CHINESE_YR.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.EURO.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.FRANC.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.POUND.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.RINGGIT.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.RUPEE.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.SINGAPORE_DOLLAR.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.US_DOLLAR.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.UNIVERSAL_CURRENCY.getRate();
}
}
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 {
@Override
public Double getRate() {
return CurrencyType.YEN.getRate();
}
}
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.
Binary file not shown.