Exemplo n.º 1
0
        public static Celcius operator -(Celcius c, Kelvin k)
        {
            Celcius c2       = (Celcius)k;
            double  cantidad = c.getCantidad() - c2.getCantidad();

            return(new Celcius(cantidad));
        }
Exemplo n.º 2
0
        public static Celcius operator -(Celcius c, Fahrenheit f)
        {
            Celcius c2       = (Celcius)f;
            double  cantidad = c.getCantidad() - c2.getCantidad();

            return(new Celcius(cantidad));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public override bool Equals(object obj)
        {
            Celcius o = (Celcius)obj;

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

            return(Math.Abs(c.getCantidad() - c2.getCantidad()) > 0.001);
        }
Exemplo n.º 6
0
        public static bool operator !=(Celcius c, Fahrenheit f)
        {
            Celcius c2 = (Celcius)f;

            return(Math.Abs(c.getCantidad() - c2.getCantidad()) > 0.001);
        }