From 72bb6040dff741e4972d779f0f6f60de1d7e1e96 Mon Sep 17 00:00:00 2001 From: Peter McCormick Date: Tue, 13 Feb 2018 23:04:38 -0500 Subject: [PATCH] Test Cases passed. --- pom.xml | 7 +- src/main/java/CurrencyConverter.java | 28 +++++ src/main/java/DELETEME | 0 src/test/java/CurrencyConverterTest.java | 104 ++++++++++++++++++ src/test/java/DELETEME | 0 target/classes/CurrencyConverter$1.class | Bin 0 -> 1165 bytes target/classes/CurrencyConverter.class | Bin 0 -> 953 bytes .../test-classes/CurrencyConverterTest.class | Bin 0 -> 2663 bytes 8 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/main/java/CurrencyConverter.java delete mode 100644 src/main/java/DELETEME create mode 100644 src/test/java/CurrencyConverterTest.java delete mode 100644 src/test/java/DELETEME create mode 100644 target/classes/CurrencyConverter$1.class create mode 100644 target/classes/CurrencyConverter.class create mode 100644 target/test-classes/CurrencyConverterTest.class diff --git a/pom.xml b/pom.xml index 682d6db..38a32ed 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,11 @@ 1.0-SNAPSHOT - + + junit + junit + 4.12 + test + \ No newline at end of file diff --git a/src/main/java/CurrencyConverter.java b/src/main/java/CurrencyConverter.java new file mode 100644 index 0000000..0bedb22 --- /dev/null +++ b/src/main/java/CurrencyConverter.java @@ -0,0 +1,28 @@ +import java.util.Map; +import java.util.TreeMap; + +public class CurrencyConverter { + + private double convertingCurrency; + + private Map conversionMap = new TreeMap() { + { + put("Us Dollar", 1.00); + put("Euro", 0.94); + put("British Pound", 0.82); + put("Indian Rupee", 68.32); + put("Australian Dollar", 1.35); + put("Canadian Dollar", 1.32); + put("Singapore Dollar", 1.43); + put("Swiss Franc", 1.01); + put("Malaysian Ringgit", 4.47); + put("Japanese Yen", 115.84); + put("Chinese Yuan Renminbi", 6.92); + } + }; + public double convertCurrentToDestinationCurrency(String current, String destination, double fatStack) { + convertingCurrency = ((conversionMap.get(destination)) / (conversionMap.get(current))) * fatStack; + return convertingCurrency; + } + +} \ 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/test/java/CurrencyConverterTest.java b/src/test/java/CurrencyConverterTest.java new file mode 100644 index 0000000..61884ee --- /dev/null +++ b/src/test/java/CurrencyConverterTest.java @@ -0,0 +1,104 @@ +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import java.util.TreeMap; + + + +public class CurrencyConverterTest { + + CurrencyConverter converter; + + @Before + public void Setup() { + converter = new CurrencyConverter(); + } + + + @Test + public void testDollarToEuro() { + double expected = 1128.00; + double actual = converter.convertCurrentToDestinationCurrency( + "Us Dollar", "Euro", 1200); + Assert.assertEquals(expected, actual,.01 ); + } + + @Test + public void testEuroToDollar() { + double expected = 2180.85; + double actual = converter.convertCurrentToDestinationCurrency( + "Euro", "Us Dollar", 2050); + Assert.assertEquals(expected, actual,.01 ); + } + + + @Test + public void testEuroToBritishPound() { + double expected = 283.51; + double actual = converter.convertCurrentToDestinationCurrency( + "Euro", "British Pound", 325); + Assert.assertEquals(expected, actual,.01 ); + } + + + @Test + public void testBritishPoundToIndianRupee() { + double expected = 185797.07; + double actual = converter.convertCurrentToDestinationCurrency( + "British Pound", "Indian Rupee", 2230); + Assert.assertEquals(expected, actual,.01 ); + } + + + @Test + public void testRupeeToCanadianDollar() { + double expected = 96.60; + double actual = converter.convertCurrentToDestinationCurrency( + "Indian Rupee", "Canadian Dollar", 5000); + Assert.assertEquals(expected, actual,.01 ); + } + + + @Test + public void testCanadianDollarToSingaporeDollar() { + double expected = 59.58; + double actual = converter.convertCurrentToDestinationCurrency( + "Canadian Dollar", "Singapore Dollar", 55); + Assert.assertEquals(expected, actual,.01 ); + } + + + @Test + public void testSingaporeDollarToSwissFranc() { + double expected = 234.49; + double actual = converter.convertCurrentToDestinationCurrency( + "Singapore Dollar", "Swiss Franc", 332); + Assert.assertEquals(expected, actual,.01 ); + } + + + @Test + public void testSwissFrancToMalaysianRinggit() { + double expected = 5421.53; + double actual = converter.convertCurrentToDestinationCurrency( + "Swiss Franc", "Malaysian Ringgit", 1225); + Assert.assertEquals(expected, actual, .01); + } + + + @Test + public void testMalaysianRinggitToJapaneseYen() { + double expected = 8292.79; + double actual = converter.convertCurrentToDestinationCurrency( + "Malaysian Ringgit", "Japanese Yen", 320); + Assert.assertEquals(expected, actual,.01 ); + } + + @Test + public void testJapaneseYenToChineseYuanRenminbi() { + double expected = 7320.84; + double actual = converter.convertCurrentToDestinationCurrency( + "Japanese Yen", "Chinese Yuan Renminbi", 122550); + Assert.assertEquals(expected, actual,.01 ); + } +} \ No newline at end of file diff --git a/src/test/java/DELETEME b/src/test/java/DELETEME deleted file mode 100644 index e69de29..0000000 diff --git a/target/classes/CurrencyConverter$1.class b/target/classes/CurrencyConverter$1.class new file mode 100644 index 0000000000000000000000000000000000000000..d79ac2e8c35d37120d580be5c008b6a246936573 GIT binary patch literal 1165 zcmZux&rcIU6#f?Kb}2}Y)I-RGjG0c-h6M~d%OGX@8>T72Cz_vI0i%L z!W|7mAq?Ygh?tay5jFiw-#wVx(>08$=^vxzci%&!8phPj;whh2(}!=o=dFeet=sn( ze?ITfFs`PLypy{J8t$p---*MoFIT%YWYtX5DW6j_s~(*=(lDWB+C1;6y&xuom{OoR z8-^Y4SJ0f#x>9mc+R0jCn@fkw6m5?f!f?hEv?l(u-@T$BkhRvhg2ucd_`JJS zO=6;XtHjI|CJhgtkO428g7AzGTxLyX+niuawRU`fqSqCSb-^50lH729lWns;*D=h# zCCT|5D~}vgCKKy@1xFfUJ#~i3SuVv*jgd~MV7aoyCk^jjtyOvUddif-geaMoO)_)b z*|64vm=5C#u7;7o3|(f~j^!-VWHN}^FzzEC#vJCU0u!#Z6g1qEhGWoY*I2&BAGd6vK_l3 zOs?yOLy=}#nF((5*kdlJn%NENg@;@(JQrJrC>qq^s>I_1Bv@5e;;K9q)F!-cM=IWx ziXYckL2#RyE?;;;ffKpz>ITr!vP-udN}SnSC~oqSbGBV4%vpgG3NiXny67uXA`!12 z-ik&7-DH!r`hx&!$i7bYe1MYtgqmcuws9YUk2v=z8C7)zeNd+(7I$C{jLB~ZOwCT9ygLWMqKIqhO`2@VDtJR=~=0P;jtf3Ae=%`00!ssO~h4Yw3 zBbE_C5lyfV#WOVH1$n(f3$D?r*5ed$9eso-*-9zs?L$AI8v4cDsMwphMK*xjH22a7 KQIXG=mqSSlF+ literal 0 HcmV?d00001 diff --git a/target/classes/CurrencyConverter.class b/target/classes/CurrencyConverter.class new file mode 100644 index 0000000000000000000000000000000000000000..bd0dea9d68f8cdebf0708b3d54d36c01d27d0259 GIT binary patch literal 953 zcmZuv-*3`T7(Ex*3Z;k)#rfO0xdFrBOnhRQ4-gX*bPp^fK3=*jcB`!^?V^8`F>x9- zF+Tf88P9EtK(IGyzh6Dycg}Zz|M~tCz&;+EFtK6azKIMr3n*Z#hzHmeR&Gx->6@-pA?nXhNJo|%y=n0gP#KiHv7xJAzxqm9pWjhKT zx6MFDpfGU8o(!Wv2|QWM9we?Sy>WXG1_bZSMS6ZTa#iP$7^?@4=Y)p>*?MCrkn8#< zL@W0lPrZ!Zj#O|gS;{f{zAfFM3>@vJ!Cd&pA%$vxI(awYq5>jsro@t5cuR%c!JJu)E!^Bd|vlA$u%vhc&v=v3JxQLFz) zHob$=!k)RAv10l5yif^7r!l8P8qzw%+Z{?bB44hxhYj98lQ%WP!x3YPe89P4yTUkC zMV0R>j66k-7Eoz^g=qdj<`s?X1#+L_@~eF7n+}%ckVlP{mHdEfSf?j&9XC?2_gLWp zTFvHXLNHR8E+kN(p->WHvDkJAOIQrM>1Mau zdhy_l-a6{VV;wy+ zJq?2T>o?D%f86167)BUd43UCm-qUSIw;8%KDc81jvv5CE6-OC_F~c;R zcNtpai9ACnWv%NB9T~&auesZ6x}DS3N~A~`tDu$gnr-msKnyvXMup+nVdtD)amc+b zt2=I);lz?_I>xr1H!23DPnf3VXpUi-lugcdF}dZ^GLn<}hGpxN*y)f#+A5VaJ7-O~ z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