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

public class CurrencyConverter {
public static Double convert(Double amountOfBaseCurrency, ConvertableCurrency sourceCurrencyType, CurrencyType targetCurrencyType) {
return sourceCurrencyType.convert(targetCurrencyType) * amountOfBaseCurrency;
public class CurrencyConverter implements ConvertableCurrency{
public static Double convert(Double amountOfBaseCurrency,
ConvertableCurrency sourceCurrencyType,
CurrencyType targetCurrencyType) {
return sourceCurrencyType.convert(targetCurrencyType) *
amountOfBaseCurrency;
}


@Override
public CurrencyType getType() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ public enum CurrencyType {
YEN(231.68);

private final double rate;
private final CurrencyType type;

CurrencyType(double rate) {
this.rate = rate;
this.type = this;
}

public Double getRate() {
return rate;
}

public static CurrencyType getTypeOfCurrency(ConvertableCurrency currency) {
return null;
return currency.getType();
}
}
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 type = CurrencyType.AUSTRALIAN_DOLLAR;

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

@Override
public CurrencyType getType() {
return this.type;
}

}
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 type = CurrencyType.CANADIAN_DOLLAR;

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

@Override
public CurrencyType getType() {
return this.type;
}
}
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 type = CurrencyType.CHINESE_YR;

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

@Override
public CurrencyType getType() {
return this.type;
}
}
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 Euro implements ConvertableCurrency {
private CurrencyType type = CurrencyType.EURO;

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

@Override
public CurrencyType getType() {
return type;
}
}
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 Franc implements ConvertableCurrency {
private CurrencyType type = CurrencyType.FRANC;

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

@Override
public CurrencyType getType() {
return this.type;
}
}
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 Pound implements ConvertableCurrency {
private CurrencyType type = CurrencyType.POUND;

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

@Override
public CurrencyType getType() {
return this.type;
}
}
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 Ringgit implements ConvertableCurrency {
private CurrencyType type = CurrencyType.RINGGIT;

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

@Override
public CurrencyType getType() {
return this.type;
}
}
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 Rupee implements ConvertableCurrency {
private CurrencyType type = CurrencyType.RUPEE;

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

@Override
public CurrencyType getType() {
return type;
}
}
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 SingaporeDollar implements ConvertableCurrency {
private CurrencyType type = CurrencyType.SINGAPORE_DOLLAR;

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

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

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

public class USDollar implements ConvertableCurrency {
private CurrencyType type = CurrencyType.US_DOLLAR;

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

public CurrencyType getType(){
return type;
}
}
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 UniversalCurrency implements ConvertableCurrency {
private CurrencyType type = CurrencyType.UNIVERSAL_CURRENCY;

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

@Override
public CurrencyType getType() {
return this.type;
}
}
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 type = CurrencyType.YEN;

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

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