Created
January 19, 2020 13:50
-
-
Save configureappio/bb5ad50704820242935c49c468f752d0 to your computer and use it in GitHub Desktop.
Interface and implementations to map temperature scales to Kelvin scale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private interface IKelvinMapper | |
{ | |
decimal ToKelvins(decimal value); | |
} | |
private class CentigradeToKelvinMapper : IKelvinMapper | |
{ | |
public decimal ToKelvins(decimal value) => value + 273.15M; | |
} | |
private class FahrenheitToKelvinMapper : IKelvinMapper | |
{ | |
public decimal ToKelvins(decimal value) => (value + 459.67M) * 5 / 9; | |
} | |
private class RankineToKelvinMapper : IKelvinMapper | |
{ | |
public decimal ToKelvins(decimal value) => value * 5 / 9; | |
} | |
private class KelvinToKelvinMapper : IKelvinMapper | |
{ | |
public decimal ToKelvins(decimal value) => value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment