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
Expand Up @@ -4,4 +4,6 @@ public interface ConvertableCurrency {
default Double convert(CurrencyType currencyType) {
return Double.MAX_VALUE;
}

CurrencyType getType();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.zipcoder.currencyconverterapplication;

import org.omg.CORBA.Current;

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

public static CurrencyType getTypeOfCurrency(ConvertableCurrency currency) {
return null;
// for (CurrencyType currencyType : CurrencyType.values()) {
// String currencyTypeName = currencyType.name().replace("_", "");
// String convertableCurrencyName = currency.getClass().getSimpleName();
// if (currencyTypeName.equalsIgnoreCase(convertableCurrencyName)) {
// return currencyType;
// }
// }
return currency.getType();
// 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,20 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class AustralianDollar implements ConvertableCurrency {

private CurrencyType result = CurrencyType.AUSTRALIAN_DOLLAR;

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

@Override
public CurrencyType getType() {
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class CanadianDollar implements ConvertableCurrency {

private CurrencyType result = CurrencyType.CANADIAN_DOLLAR;
@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.CANADIAN_DOLLAR.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class ChineseYR implements ConvertableCurrency {

private CurrencyType result = CurrencyType.CHINESE_YR;
@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.CHINESE_YR.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class Euro implements ConvertableCurrency {

CurrencyType result = CurrencyType.EURO;

@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.EURO.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class Franc implements ConvertableCurrency {

private CurrencyType result = CurrencyType.FRANC;

@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.FRANC.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class Pound implements ConvertableCurrency {

private CurrencyType result = CurrencyType.POUND;

@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.POUND.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class Ringgit implements ConvertableCurrency {

private CurrencyType result = CurrencyType.RINGGIT;

@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.RINGGIT.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class Rupee implements ConvertableCurrency {

private CurrencyType result = CurrencyType.RUPEE;

@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.RUPEE.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class SingaporeDollar implements ConvertableCurrency {

private CurrencyType result = CurrencyType.SINGAPORE_DOLLAR;

@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.SINGAPORE_DOLLAR.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class USDollar extends CurrencyConverter implements ConvertableCurrency {

private CurrencyType result = CurrencyType.US_DOLLAR;

@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.US_DOLLAR.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
return result;
}


public class USDollar implements ConvertableCurrency {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class UniversalCurrency implements ConvertableCurrency {

private CurrencyType result = CurrencyType.UNIVERSAL_CURRENCY;

@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.UNIVERSAL_CURRENCY.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
package io.zipcoder.currencyconverterapplication.currencies;

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

public class Yen implements ConvertableCurrency {

private CurrencyType result = CurrencyType.YEN;
@Override
public Double convert(CurrencyType currencyType) {
Double universalAmount = currencyType.getRate() / CurrencyType.YEN.getRate();
return universalAmount;
}

@Override
public CurrencyType getType() {
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.
Binary file not shown.