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..b412c1f 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,32 +1,16 @@ - - - - - - - - - - - - - - - - + - - + \ No newline at end of file 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..e8942bd 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,8 +1,5 @@ - - - - - - - - - - - - - - + - - - - - 1.8 - - - - - - - \ 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..4e3316b 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..586679c 100644 --- a/src/main/java/ConversionTool.java +++ b/src/main/java/ConversionTool.java @@ -3,19 +3,55 @@ 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 centimeters/2.54f; + } + + public static float InchesToCentimeters(float inches){ + if(inches <0){ + return 0; + } + return inches*2.54f; + } + + public static float FeetToMeters(float feet){ + if(feet < 0){ + return 0; + } + return feet* 0.3048f; + } + + public static float MetersToFeet(float meters){ + if(meters < 0){ + return 0; + } + return meters/0.3048f; + } + + public static float CelsiusToFahrenheit(float celsius){ + return (celsius*1.8f)+32; + } + + public static float FahrenheitToCelsius(float fahrenheit){ + return (fahrenheit-32)*.5556f; + + } + + public static float MphToKph(float mph){ + if(mph < 0){ + return 0; + } + return mph*1.609344f; + } + + public static float KphToMph(float kph){ + if(kph < 0){ + return 0; + } + return kph/1.609344f; + } } diff --git a/src/test/java/ConversionToolSpec.java b/src/test/java/ConversionToolSpec.java index 5bbfb07..e1f8dc5 100644 --- a/src/test/java/ConversionToolSpec.java +++ b/src/test/java/ConversionToolSpec.java @@ -78,6 +78,12 @@ public void shouldConvertCelsiusToFahrenheit() { assertEquals(80, fahrenheit, 0.01); } + @Test + public void shouldConvertCelsiusToFahrenheitBelowZero() { + float fahrenheit = ConversionTool.CelsiusToFahrenheit(-4.33f); + assertEquals(24.206, 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 7d20ebc..c62a336 100644 Binary files a/target/classes/ConversionTool.class and b/target/classes/ConversionTool.class differ diff --git a/target/test-classes/ConversionToolSpec.class b/target/test-classes/ConversionToolSpec.class index 2cc6d49..6dcbacc 100644 Binary files a/target/test-classes/ConversionToolSpec.class and b/target/test-classes/ConversionToolSpec.class differ