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 7d20ebc..e578478 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..929972b 100644 Binary files a/target/test-classes/ConversionToolSpec.class and b/target/test-classes/ConversionToolSpec.class differ