Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

81 changes: 41 additions & 40 deletions RepeatedEditsDemo/TemperatureConversions.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
namespace Refactorings

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

public static class TemperatureConversions
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static class TemperatureConversions
public static class TemperatureConversions
Suggested change
public static class TemperatureConversions
public static class TemperatureConversions
Suggested change
public static class TemperatureConversions
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)
/// <summary>
/// Converts temperatures from one unit of measure to another
/// </summary>
/// <param name="Conversion">the input and output units desired</param>
/// <param name="temperature">temperature to be converted</param>
/// <returns>temperature in the specified output unit</returns>
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);
}

/// <summary>
/// Converts temperatures from one unit of measure to another
/// </summary>
/// <param name="Conversion">the input and output units desired</param>
/// <param name="temperature">temperature to be converted</param>
/// <returns>temperature in the specified output unit</returns>
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;
}
/// <summary>
/// Temperature units for conversion
/// </summary>
public enum Conversion{ FtoC, CtoF }

return outTemperature;
}
/// <summary>
/// Temperature units for conversion
/// </summary>
public enum Conversion{ FtoC, CtoF }

#region Name
}
}

#endregion