static void Main(string[] args) { Celsius c = 10; Kelvin k = (Kelvin)c; Fahrenheit f = (Fahrenheit)c; Fahrenheit f2 = 90; Celsius c2 = (Celsius)f2; Kelvin k2 = (Kelvin)f2; Kelvin k3 = 400; Celsius c3 = (Celsius)k3; Fahrenheit f3 = (Fahrenheit)k3; Console.WriteLine("---------------------------------------------------------------------------------"); Console.WriteLine("---------------------------------------------------------------------------------"); Console.WriteLine($"{c.GetTemperatura()} Celsius a Kelvin: {k.GetTemperatura()}"); Console.WriteLine($"{c.GetTemperatura()} Celsius a Fahrenheit: {f.GetTemperatura()}"); Console.WriteLine("---------------------------------------------------------------------------------"); Console.WriteLine("---------------------------------------------------------------------------------"); Console.WriteLine($"{k3.GetTemperatura()} Kelvin a Celsius: {c3.GetTemperatura()}"); Console.WriteLine($"{k3.GetTemperatura()} Kelvin a Fahrenheit: {f3.GetTemperatura()}"); Console.WriteLine("---------------------------------------------------------------------------------"); Console.WriteLine("---------------------------------------------------------------------------------"); Console.WriteLine($"{f2.GetTemperatura()} Fahrenheit a Kelvin: {k2.GetTemperatura()}"); Console.WriteLine($"{f2.GetTemperatura()} Fahrenheit a Celsius: {c2.GetTemperatura()}"); Console.WriteLine("---------------------------------------------------------------------------------"); Console.WriteLine("---------------------------------------------------------------------------------"); Console.ReadKey(true); }
static void Main(string[] args) { Celsius celsius = new Celsius(10); Kelvin kelvin = new Kelvin(298); Fahrenheit fahrenheit = new Fahrenheit(77); Console.WriteLine("***** Resultados en Celsius *****"); Celsius cAux = (Celsius)fahrenheit; Console.WriteLine("{0} Fahrenheit son {1} Celsius: ", fahrenheit.GetTemperatura(), cAux.GetTemperatura()); cAux = (Celsius)kelvin; Console.WriteLine("{0} Kelvin son {1} Celsius: ", kelvin.GetTemperatura(), cAux.GetTemperatura()); Console.WriteLine("\n***** Resultados en Kelvin *****"); Kelvin kAux = (Kelvin)fahrenheit; Console.WriteLine("{0} Fahrenheit son {1} Kelvin: ", fahrenheit.GetTemperatura(), kAux.GetTemperatura()); kAux = (Kelvin)celsius; Console.WriteLine("{0} Celsius son {1} Kelvin: ", celsius.GetTemperatura(), kAux.GetTemperatura()); Console.WriteLine("\n***** Resultados en Fahrenheit *****"); Fahrenheit fAux = (Fahrenheit)kelvin; Console.WriteLine("{0} Kelvin son {1} Fahrenheit: ", kelvin.GetTemperatura(), fAux.GetTemperatura()); fAux = (Fahrenheit)celsius; Console.WriteLine("{0} Celsius son {1} Fahrenheit: ", celsius.GetTemperatura(), fAux.GetTemperatura()); Console.ReadKey(); }
static void Main(string[] args) { Kelvin kelvin = new Kelvin(50); Celsius celsius = new Celsius(60); Fahrenheit fahrenheit = new Fahrenheit(2000); Console.WriteLine("CALCULAR CAMBIO DE TEMPERATURAS "); Console.WriteLine("Fahrenheit a Celsius: " + ((Celsius)fahrenheit).GetTemperatura() + " ~~ Kelvin a Celsius: " + ((Celsius)kelvin).GetTemperatura()); Console.WriteLine("Celsius a Kelvin: " + ((Kelvin)celsius).GetTemperatura() + " ~~ Fahrenheit a Kelvin: " + ((Kelvin)fahrenheit).GetTemperatura()); Console.WriteLine("Kelvin a Fahrenheit: " + ((Fahrenheit)kelvin).GetTemperatura() + " ~~ Celcius a Fahrenheit: " + ((Fahrenheit)celsius).GetTemperatura()); Console.WriteLine("\n SUMA ENTRE TEMPERATURAS"); Console.WriteLine("La suma entre :{0} Fahrenheit y {1} ", fahrenheit.GetTemperatura(), ((Fahrenheit)kelvin).GetTemperatura() + " Kelvin, en Fahrenheit es de: " + (fahrenheit + kelvin).GetTemperatura()); Console.WriteLine("La suma entre :{0} Celsius y {1} ", celsius.GetTemperatura(), ((Celsius)kelvin).GetTemperatura() + " kelvin, en Celsius es de: " + (celsius + kelvin).GetTemperatura()); Console.WriteLine("La Resta entre :{0} Fahrenheit y {1} ", fahrenheit.GetTemperatura(), ((Fahrenheit)celsius).GetTemperatura() + " Celsius, en Fahrenheit es de: " + (fahrenheit - celsius).GetTemperatura()); Console.WriteLine("La Resta entre :{0} Kelvin y {1} ", ((Kelvin)kelvin).GetTemperatura(), ((Kelvin)celsius).GetTemperatura() + " Celsius, en Kelvin es de: " + (kelvin - celsius).GetTemperatura()); Console.ReadKey(); }
public static bool operator ==(Celsius celsius, Fahrenheit fahrenheit) { return(celsius.GetTemperatura() == fahrenheit.GetTemperatura()); }
public static bool operator ==(Fahrenheit f1, Fahrenheit f2) { return(f1.GetTemperatura() == f2.GetTemperatura()); }
public static bool operator ==(Kelvin kelvin, Fahrenheit fahrenheit) { return(kelvin.GetTemperatura() == fahrenheit.GetTemperatura()); }