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
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<version>1.0-SNAPSHOT</version>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies>
</project>
Empty file removed src/main/java/DELETEME
Empty file.
32 changes: 32 additions & 0 deletions src/main/java/WuTangFinancial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.text.NumberFormat;
import java.util.TreeMap;
import java.text.DecimalFormat;

public class WuTangFinancial {


public TreeMap<String, Double> convertList;

public WuTangFinancial () {
convertList = new TreeMap<String, Double>();
//initialization of object TreeMap
convertList.put("USD", 1.00);
convertList.put("Euro", 0.94);
convertList.put("Pound", 0.82);
convertList.put("Rupee", 68.32);
convertList.put("Australian Dollar", 1.35);
convertList.put("Canadian Dollar", 1.32);
convertList.put("Singapore Dollar", 1.43);
convertList.put("Swiss Franc", 1.01);
convertList.put("Malaysian Ringgit", 4.47);
convertList.put("Japanese Yen", 115.84);
convertList.put("Chinese Yuan Renminbi", 6.92);
}

public String currencyConverter(String beginning, String ending, Double amountToConvert) {
DecimalFormat df=new DecimalFormat("###.##");
String result = df.format(this.convertList.get(ending)/ this.convertList.get(beginning) * amountToConvert);
return result;
}

}
Empty file removed src/test/java/DELETEME
Empty file.
18 changes: 18 additions & 0 deletions src/test/java/WuTangFinancial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//import javax.xml.bind.annotation.XmlAnyAttribute;
//import
//
//public class WuTangFinancial {
// private WuTangFinancial conversionRatesTest;
//
//}
//@Before
//
//
//@Test
//String beginning "USD";
//String ending "Euro";
//Double amountToConvert 5.00;
//Double expected 4.70;
//WuTangFinancial wutangFinancial = new WuTangFinancial(amountToConvert);
//Double actual wutangFinancial.convertionRateMethod(amountToConvert, beginningCurrency, endingCurrency);;
//Assert.assertEquals(expected, actual, delta);
99 changes: 99 additions & 0 deletions src/test/java/WuTangFinancialTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.util.TreeMap;

public class WuTangFinancialTest {

public WuTangFinancial test = new WuTangFinancial();

@Before
public void setUp() {

}

@Test
public void testCurrencyConverter() {
String expected = "470";
String actual = test.currencyConverter("USD","Euro",500.00);

Assert.assertEquals(expected,actual);
}
public void dollarToEuro() {
String expected = "470";
String actual = test.currencyConverter("USD", "Euro", 500.00);
Assert.assertEquals(expected, actual);
}


@Test
public void britishPoundToDollar() {
String expected = "609.76";
String actual = test.currencyConverter("Pound", "USD", 500.00);
Assert.assertEquals(expected, actual);
}


@Test
public void euroToBritishPound() {
String expected = "436.17";
String actual = test.currencyConverter("Euro", "Pound", 500.00);
Assert.assertEquals(expected, actual);
}


@Test
public void britishPoundToIndianRupee() {
String expected = "41658.54";
String actual = test.currencyConverter("Pound", "Rupee", 500.00);
Assert.assertEquals(expected, actual);
}


@Test
public void rupeeToCanadianDollar() {
String expected = "9.66";
String actual = test.currencyConverter("Rupee", "Canadian Dollar", 500.00);
Assert.assertEquals(expected, actual);
}


@Test
public void canadianDollarToSingaporeDollar() {
String expected = "541.67";
String actual = test.currencyConverter("Canadian Dollar", "Singapore Dollar", 500.00);
Assert.assertEquals(expected, actual);
}

@Test
public void SingaporeDollarToSwissFranc() {
String expected = "353.15";
String actual = test.currencyConverter("Singapore Dollar", "Swiss Franc", 500.00);
Assert.assertEquals(expected, actual);
}

@Test
public void SwissFrancToMalaysianRinggit() {
String expected = "2212.87";
String actual = test.currencyConverter("Swiss Franc", "Malaysian Ringgit", 500.00);
Assert.assertEquals(expected, actual);
}

@Test
public void MalaysianRinggitToJapaneseYen() {
String expected = "12957.49";
String actual = test.currencyConverter("Malaysian Ringgit", "Japanese Yen", 500.00);
Assert.assertEquals(expected, actual);
}

@Test
public void JapaneseYenToChineseYuanRenminbi() {
String expected = "29.87";
String actual = test.currencyConverter("Japanese Yen", "Chinese Yuan Renminbi", 500.00);
Assert.assertEquals(expected, actual);
}



}
Binary file added target/classes/WuTangFinancial.class
Binary file not shown.
Binary file added target/test-classes/WuTangFinancialTest.class
Binary file not shown.