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
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,15 @@

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies>
</project>
14 changes: 14 additions & 0 deletions src/main/java/Converter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Converter {


static double convertCurrency(double from, double to){
return convertToDollar(from) * to;
}
static double convertToDollar(double from){
return ExchangeRates.USDollar / from;
}
// static double convertFromDollar(double to){
// double targetAmount = to / ExchangeRates.USDollar;
// return targetAmount;
// }
}
Empty file removed src/main/java/DELETEME
Empty file.
29 changes: 29 additions & 0 deletions src/main/java/ExchangeRates.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

public class ExchangeRates {

final static double USDollar = 1.00;
final static double Euro = 0.94;
final static double BritishPound = 0.82;
final static double IndianRupee = 68.32;
final static double CanadianDollar = 1.32;
final static double SingaporeDollar = 1.43;
final static double SwissFranc = 1.01;
final static double MalaysianRinggit = 4.47;
final static double JapaneseYen = 115.84;
final static double ChineseYuanRenminbi = 6.92;

}














90 changes: 90 additions & 0 deletions src/test/java/ConverterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import org.junit.Test;
import org.omg.CORBA.CODESET_INCOMPATIBLE;

import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;

public class ConverterTest {

@Test
public void convertToDollarTest(){
//Euro to Dollar
double expected = 1.06;
double actual = Converter.convertToDollar(ExchangeRates.Euro);
assertEquals(expected, actual, 0.5);
}
// @Test
// public void convertFromDollarTest(){
// double expected = 0.94;
// double actual = Converter.convertFromDollar(ExchangeRates.Euro);
// assertEquals(expected, actual);
// }
@Test
public void convertCurrencyTest2(){
//Dollar to Euro
double expected = 0.94;
double actual = Converter.convertCurrency(ExchangeRates.USDollar, ExchangeRates.Euro);
assertEquals(expected, actual);
}
@Test
public void convertCurrencyTest3(){
//Euro to BritishPound
double expected = 0.86;
double actual = Converter.convertCurrency(ExchangeRates.Euro, ExchangeRates.BritishPound);
assertEquals(expected, actual, 0.5);
}
@Test
public void convertCurrencyTest4(){
//British Pound to Indian Rupee
double expected = 83.32;
double actual = Converter.convertCurrency(ExchangeRates.BritishPound, ExchangeRates.IndianRupee);
assertEquals(expected, actual, 0.5);
}
@Test
public void convertCurrencyTest5(){
//Indian Rupee to Canadian Dollar
double expected = 0.02;
double actual = Converter.convertCurrency(ExchangeRates.IndianRupee, ExchangeRates.CanadianDollar);
assertEquals(expected, actual, 0.5);
}
@Test
public void convertCurrencyTest6(){
//Canadian Dollar to Singapore Dollar
double expected = 1.08;
double actual = Converter.convertCurrency(ExchangeRates.CanadianDollar, ExchangeRates.SingaporeDollar);
assertEquals(expected,actual, 0.5);
}
@Test
public void convertCurrencyTest7(){
//Singapore Dollar to Swiss Franc
double expected = 0.71;
double actual = Converter.convertCurrency(ExchangeRates.SingaporeDollar, ExchangeRates.SwissFranc);
assertEquals(expected, actual,0.5);
}
@Test
public void convertCurrencyTest8(){
//Swiss Franc to Malaysian Ringgit
double expected= 4.43;
double actual = Converter.convertCurrency(ExchangeRates.SwissFranc, ExchangeRates.MalaysianRinggit);
assertEquals(expected, actual,0.5);
}
@Test
public void convertCurrencyTest9(){
//Malaysian Ringgit to Japanese Yen
double expected = 25.91;
double actual = Converter.convertCurrency(ExchangeRates.MalaysianRinggit, ExchangeRates.JapaneseYen);
assertEquals(expected, actual,0.5);
}
@Test
public void convertCurrencyTest10(){
//Japanese Yen to Chinese Yuan Renminbi
double expected = 0.06;
double actual = Converter.convertCurrency(ExchangeRates.JapaneseYen, ExchangeRates.ChineseYuanRenminbi);
assertEquals(expected, actual,0.5);
}





}
Empty file removed src/test/java/DELETEME
Empty file.
Binary file added target/classes/Converter.class
Binary file not shown.
Binary file added target/classes/ExchangeRates.class
Binary file not shown.
Binary file added target/test-classes/ConverterTest.class
Binary file not shown.