diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ff30235 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1 @@ +} \ No newline at end of file diff --git a/RepeatedEditsDemo/TemperatureConversions.cs b/RepeatedEditsDemo/TemperatureConversions.cs index 6f526b6..0093236 100644 --- a/RepeatedEditsDemo/TemperatureConversions.cs +++ b/RepeatedEditsDemo/TemperatureConversions.cs @@ -1,50 +1,51 @@ -namespace Refactorings + +public static class TemperatureConversions { - public static class TemperatureConversions + public static double FtoC(double temperatureInF) { - public static double FtoC(double temperatureInF) - { - //T(°C) = (T(°F) - 32) × 5 / 9 - double temperatureInC = (temperatureInF - 32) * (5.0 / 9.0); - return temperatureInC; - } + //T(°C) = (T(°F) - 32) × 5 / 9 + double temperatureInC = (temperatureInF - 32) * (5.0 / 9.0); + return temperatureInC; + } + + public static double CtoF(double temperatureInC) + { + //T(°F) = (T(°C) × 9 / 5) + 32 + double temperatureInF = (temperatureInC * (9.0 / 5.0)) + 32; + return temperatureInF; + } - public static double CtoF(double temperatureInC) + /// + /// Converts temperatures from one unit of measure to another + /// + /// the input and output units desired + /// temperature to be converted + /// temperature in the specified output unit + public static double Convert(Conversion conversion, double temperature) + { + double outTemperature = temperature; + + if (conversion == Conversion.FtoC) { - //T(°F) = (T(°C) × 9 / 5) + 32 - double temperatureInF = (temperatureInC * (9.0 / 5.0)) + 32; - return temperatureInF; + //F to C: T(°C) = (T(°F) - 32) × 5 / 9 + outTemperature = (temperature - 32) * (5.0 / 9.0); } - - /// - /// Converts temperatures from one unit of measure to another - /// - /// the input and output units desired - /// temperature to be converted - /// temperature in the specified output unit - public static double Convert(Conversion conversion, double temperature) + + if(conversion == Conversion.CtoF) { - double outTemperature = temperature; - - if (conversion == Conversion.FtoC) - { - //F to C: T(°C) = (T(°F) - 32) × 5 / 9 - outTemperature = (temperature - 32) * (5.0 / 9.0); - } - - if(conversion == Conversion.CtoF) - { - //C to F: T(°F) = (T(°C) × 9 / 5) + 32 - outTemperature = (temperature * (9.0 / 5.0)) + 32; + //C to F: T(°F) = (T(°C) × 9 / 5) + 32 + outTemperature = (temperature * (9.0 / 5.0)) + 32; - } - - return outTemperature; } - /// - /// Temperature units for conversion - /// - public enum Conversion{ FtoC, CtoF } + return outTemperature; + } + /// + /// Temperature units for conversion + /// + public enum Conversion{ FtoC, CtoF } + +#region Name } -} + +#endregion \ No newline at end of file