diff --git a/pom.xml b/pom.xml index 682d6db..5057755 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,10 @@ 1.0-SNAPSHOT - + + junit + junit + RELEASE + \ No newline at end of file diff --git a/src/main/java/DELETEME b/src/main/java/DELETEME deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/java/WuTangFinancial.java b/src/main/java/WuTangFinancial.java new file mode 100644 index 0000000..079b228 --- /dev/null +++ b/src/main/java/WuTangFinancial.java @@ -0,0 +1,32 @@ +import java.text.NumberFormat; +import java.util.TreeMap; +import java.text.DecimalFormat; + +public class WuTangFinancial { + + + public TreeMap convertList; + + public WuTangFinancial () { + convertList = new TreeMap(); + //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; + } + + } diff --git a/src/test/java/DELETEME b/src/test/java/DELETEME deleted file mode 100644 index e69de29..0000000 diff --git a/src/test/java/WuTangFinancial.java b/src/test/java/WuTangFinancial.java new file mode 100644 index 0000000..9ecd1ff --- /dev/null +++ b/src/test/java/WuTangFinancial.java @@ -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); \ No newline at end of file diff --git a/src/test/java/WuTangFinancialTest.java b/src/test/java/WuTangFinancialTest.java new file mode 100644 index 0000000..6c864e0 --- /dev/null +++ b/src/test/java/WuTangFinancialTest.java @@ -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); + } + + + +} \ No newline at end of file diff --git a/target/classes/WuTangFinancial.class b/target/classes/WuTangFinancial.class new file mode 100644 index 0000000..379f49f Binary files /dev/null and b/target/classes/WuTangFinancial.class differ diff --git a/target/test-classes/WuTangFinancialTest.class b/target/test-classes/WuTangFinancialTest.class new file mode 100644 index 0000000..2ea5c39 Binary files /dev/null and b/target/test-classes/WuTangFinancialTest.class differ