Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Celcius    c = new Celcius(100);
            Kelvin     k = new Kelvin(100);
            Fahrenheit f = new Fahrenheit(100);

            Console.WriteLine("\nCELCIUS");
            Console.WriteLine("{0}°C = {1:#.##}°K", c.getCantidad(), ((Kelvin)c).getCantidad());
            Console.WriteLine("{0}°C = {1:#.##}°F", c.getCantidad(), ((Fahrenheit)c).getCantidad());

            Console.WriteLine("\nKELVIN");
            Console.WriteLine("{0}°K = {1:#.##}°C", k.getCantidad(), ((Celcius)k).getCantidad());
            Console.WriteLine("{0}°K = {1:#.##}°F", k.getCantidad(), ((Fahrenheit)k).getCantidad());

            Console.WriteLine("\nFAHRENHEIT");
            Console.WriteLine("{0}°F = {1:#.##}°K", f.getCantidad(), ((Kelvin)f).getCantidad());
            Console.WriteLine("{0}°F = {1:#.##}°C", f.getCantidad(), ((Celcius)f).getCantidad());

            Console.WriteLine("\nCOMPARACIONES");
            f = new Fahrenheit(212);
            Console.WriteLine("¿{0}°C == {1}°F? = {2}", c.getCantidad(), f.getCantidad(), c == f);
            f = new Fahrenheit(211);
            Console.WriteLine("¿{0}°C == {1}°F? = {2}", c.getCantidad(), f.getCantidad(), c == f);
            f = new Fahrenheit(-279.67);
            Console.WriteLine("¿{1}°K == {0}°F? = {2}", f.getCantidad(), k.getCantidad(), f == k);
            f = new Fahrenheit(-279.66);
            Console.WriteLine("¿{1}°K == {0}°F? = {2}", f.getCantidad(), k.getCantidad(), f == k);
        }
Ejemplo n.º 2
0
        public static Kelvin operator -(Kelvin k, Celcius c)
        {
            Kelvin k2       = (Kelvin)c;
            double cantidad = k.getCantidad() - k2.getCantidad();

            return(new Kelvin(cantidad));
        }
Ejemplo n.º 3
0
        public static Kelvin operator -(Kelvin k, Fahrenheit f)
        {
            Kelvin k2       = (Kelvin)f;
            double cantidad = k.getCantidad() - k2.getCantidad();

            return(new Kelvin(cantidad));
        }
Ejemplo n.º 4
0
        public override bool Equals(object obj)
        {
            Kelvin o = (Kelvin)obj;

            if (ReferenceEquals(null, o))
            {
                return(false);
            }
            if (ReferenceEquals(this, o))
            {
                return(true);
            }
            return(Math.Abs(this.getCantidad() - o.getCantidad()) < 0.001);
        }
Ejemplo n.º 5
0
        public static bool operator ==(Kelvin k, Celcius c)
        {
            Kelvin k2 = (Kelvin)c;

            return(Math.Abs(k.getCantidad() - k2.getCantidad()) < 0.001);
        }
Ejemplo n.º 6
0
        public static bool operator !=(Kelvin k, Fahrenheit f)
        {
            Kelvin k2 = (Kelvin)f;

            return(Math.Abs(k.getCantidad() - k2.getCantidad()) > 0.001);
        }