From 751d3251f98593cd338eb6718c4ebf50619ba08d Mon Sep 17 00:00:00 2001 From: Molly Arant Date: Fri, 12 May 2017 10:42:42 -0400 Subject: [PATCH] completed conversions --- .idea/.name | 1 + .idea/compiler.xml | 18 +---- .idea/copyright/profiles_settings.xml | 3 - .idea/encodings.xml | 6 -- .idea/kotlinc.xml | 7 ++ .idea/misc.xml | 49 ++++++++++---- .idea/vcs.xml | 6 ++ conversion.iml | 3 +- src/main/java/ConversionTool.java | 65 ++++++++++++++----- src/test/java/ConversionToolSpec.java | 1 + target/classes/ConversionTool.class | Bin 1471 -> 1275 bytes target/test-classes/ConversionToolSpec.class | Bin 3584 -> 3584 bytes 12 files changed, 102 insertions(+), 57 deletions(-) create mode 100644 .idea/.name delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/encodings.xml create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..5966089 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +conversion \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 3c5f7fa..7ec525c 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,27 +1,11 @@ - - - - - - - - - - - - - - - - + - diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..1c24f9a --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index dfca8c4..0f82c90 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,8 +1,5 @@ - - - - - - - - - - - - - - + + + + + + + + + + + 1.8 + + + + + 1.8 @@ -37,6 +47,17 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/conversion.iml b/conversion.iml index 4b044f1..0ddf51c 100644 --- a/conversion.iml +++ b/conversion.iml @@ -1,11 +1,10 @@ - + - diff --git a/src/main/java/ConversionTool.java b/src/main/java/ConversionTool.java index df73653..0fdc780 100644 --- a/src/main/java/ConversionTool.java +++ b/src/main/java/ConversionTool.java @@ -3,19 +3,54 @@ public class ConversionTool { public static void main(String[] args){} - public static float CentimetersToInches(float centimeters){} - - public static float InchesToCentimeters(float inches){} - - public static float FeetToMeters(float feet){} - - public static float MetersToFeet(float meters){} - - public static float CelsiusToFahrenheit(float celsius){} - - public static float FahrenheitToCelsius(float fahrenheit){} - - public static float MphToKph(float mph){} - - public static float KphToMph(float kph){} + public static float CentimetersToInches(float centimeters){ + if(centimeters<0){ + return 0; + } + return (float)(centimeters/2.54); + } + + public static float InchesToCentimeters(float inches){ + if(inches<0){ + return 0; + } + return (float)(inches*2.54); + } + + public static float FeetToMeters(float feet){ + if(feet<0){ + return 0; + } + return (float)(feet/3.28084); + } + + public static float MetersToFeet(float meters){ + if(meters<0){ + return 0; + } + return (float)(meters*3.28084); + } + + public static float CelsiusToFahrenheit(float celsius){ + + return (float)(celsius*1.8+32); + } + + public static float FahrenheitToCelsius(float fahrenheit){ + return (float)((fahrenheit-32)/1.8); + } + + public static float MphToKph(float mph){ + if(mph<0){ + return 0; + } + return (float)(mph*1.609344); + } + + public static float KphToMph(float kph){ + if(kph<0){ + return 0; + } + return (float)(kph/1.609344); + } } diff --git a/src/test/java/ConversionToolSpec.java b/src/test/java/ConversionToolSpec.java index 5bbfb07..bbc1a4b 100644 --- a/src/test/java/ConversionToolSpec.java +++ b/src/test/java/ConversionToolSpec.java @@ -78,6 +78,7 @@ public void shouldConvertCelsiusToFahrenheit() { assertEquals(80, fahrenheit, 0.01); } + @Test public void shouldConvertMphToKph(){ float kph = ConversionTool.MphToKph(24f); diff --git a/target/classes/ConversionTool.class b/target/classes/ConversionTool.class index 7d20ebc7517733b6c814cac4fcef422936d99bfb..e578478ad099c00b7e3814301761f4037b0f4c99 100644 GIT binary patch literal 1275 zcmaiy&2JJx6u{rK+XZ)5*aF3>{jgXS`h|_!nA8X^To!kuI4b{TgJ&fD9_ z>6pwRkj+1-9h%2xv28ld;=boHr@8ItG2JFcrcW`Wwn80`b*P6(gYP<)P0?4%R|{1F zsx>eYAgDh-u)FfEJt$F0AMsWb<>kyR3(KtETNz$EFO; zF^l?Iv=7uGVW?Fa5$E{ck!|q%M>Y<%BV-)+Sb(o+390P!o@>!66O&C34{t-vOM@in z1QNq0ob+Ir59^22@?Z(h;sX#%0lYWRQBLEjh+l%=sg?IY-r;5fQYd9#iAiy<1rCsb z89beVESy7)2wug%2p$QPB7p>E;k+Ms0WOAtJ0SUidQN@)2By@L+{+A1@K-137Zi|y zN!-Vs z#nPcbtYSUW1K#~=n$^%chnj8hyKiJp%Qz8euvW3mGu=KhEK{|t z&I)w8nqdkwRD4`(YiC-yqnStL1IISZqZOB<*+D2Xbi}e^ zwNw=-)95(`5@1Q#nqydK#qcBZUW#f3bOe&Cy6&jft}6?J2Eu-fy*JtYdRuQeG=(3K#WVB2fCS269mK7SUBI50`%JC{rRh*{Of*x@jSoxZ_tV@p9nKKipD+{PA8?395*M&0=s3sq%s{pL)DX%mD D0O%S^ delta 115 zcmZpWX^`1)o|`k6fsG-AL69MIasjva