Example #1
0
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Pesos xPesosE = new Pesos(28.65D, 21F);
            Pesos xPesosD = new Pesos(45D, 21F);
            Euro  xEuro   = new Euro(1D, 0.7330F);
            Euro  xEuro2  = new Euro(2D, 0.7330F);
            Dolar xDolar  = new Dolar(2D, 1F);
            Dolar xDolar2 = new Dolar(2.7286D, 1F);

            Dolar restaD = xDolar2 - xEuro;
            Dolar restaE = xDolar - xPesosD;

            //bool xresult = xPesosE != xEuro;

            //xEuro = (Pesos)xEuro;
            //xDolar = (Pesos)xDolar;
            //xPesosE = (Pesos)xEuro;
            //xPesosD = (Pesos)xDolar;



            //Console.WriteLine("{0} Euros equivalen a {1} Pesos", xEuro.GetCantidad(), Math.Round(xPesosE.GetCantidad(),2));
            //Console.WriteLine("{0} Dólares equivalen a {1} Pesos",xDolar.GetCantidad() ,Math.Round(xPesosD.GetCantidad(),2));
            Console.WriteLine("{0} Dolares - {1} Euros es??: ${2}", xDolar2.GetCantidad(), xEuro.GetCantidad(), restaD.GetCantidad());  //1,3643 Dolares
            Console.WriteLine("{0} Dolares - {1} Pesos es??: ${2}", xDolar.GetCantidad(), xPesosD.GetCantidad(), restaE.GetCantidad()); //-0,14 Dolares
            //Console.WriteLine("{0} Dolares es Igual a {1} Dolares??: {2}", xDolar.GetCantidad(), xEuro2.GetCantidad(), xDolar == xDolar2);
            Console.ReadKey();
        }
Example #2
0
        public static Pesos operator +(Pesos p, Euro e)
        {
            Pesos aux     = (Pesos)e;
            Pesos retorno = new Pesos(p.cantidad + aux.cantidad);

            return(retorno);
        }
Example #3
0
        public static Pesos operator -(Pesos p, Dolar d)
        {
            Pesos aux     = (Pesos)d;
            Pesos retorno = new Pesos(p.cantidad - aux.cantidad);

            return(retorno);
        }
Example #4
0
        public static Pesos operator +(Pesos p, Euro e)
        {
            Pesos p1     = (Pesos)e;
            Pesos pFinal = new Pesos(p.GetCantidad() + p1.GetCantidad(), GetCotizacion());

            return(pFinal);
        }
Example #5
0
        static void Main(string[] args)
        {
            Euro  e = new Euro(10, 1.0937f);
            Dolar d = new Dolar(10);
            Pesos p = new Pesos(10, 64.62f);

            Console.WriteLine("Pesos {0}:", Pesos.GetCotizacion());
            Euro aux_e = e + d;

            Console.WriteLine("Euro + Dólar (€18,09xx): {0}", aux_e.GetCantidad());
            aux_e = e + p;
            Console.WriteLine("Euro + Pesos (€10,40xx): {0}", aux_e.GetCantidad());
            Console.WriteLine("----------------------------------------------");

            Dolar aux_d = d + e;

            Console.WriteLine("Dólar + Euro (U$S22,36xx): {0}", aux_d.GetCantidad());
            aux_d = d + p;
            Console.WriteLine("Dólar + Pesos (U$S10,49xx): {0}", aux_d.GetCantidad());
            Console.WriteLine("----------------------------------------------");

            Pesos aux_p = p + e;

            Console.WriteLine("Pesos + Euro ($259,26xx): {0}", aux_p.GetCantidad());
            aux_p = p + d;
            Console.WriteLine("Pesos + Dólar ($211,65xx): {0}", aux_p.GetCantidad());

            Console.ReadKey();
        }
Example #6
0
        public static Pesos operator +(Pesos p, Euro e)
        {
            Pesos p1 = (Pesos)e;

            p1.cantidad += p.cantidad;
            return(p1);
        }
Example #7
0
        public static Pesos operator +(Pesos p, Dolar d)
        {
            Pesos p1 = (Pesos)d;

            p1.cantidad += p.cantidad;
            return(p1);
        }
Example #8
0
        static void Main(string[] args)
        {
            Euro  e = new Euro(1);
            Dolar d = new Dolar(10);
            Pesos p = new Pesos(100);


            Console.WriteLine("--- TESTS DE IGUALDAD Y DESIGUALDAD ---");
            Console.WriteLine(e != d);
            Console.WriteLine(e == d);

            Console.WriteLine(e != p);
            Console.WriteLine(e == p);

            Console.WriteLine(d != e);
            Console.WriteLine(d == e);

            Console.WriteLine(d != p);
            Console.WriteLine(d == p);

            Console.WriteLine(p != d);
            Console.WriteLine(p == d);

            Console.WriteLine(p != e);
            Console.WriteLine(p == e);

            Console.WriteLine(e == e);
            Console.WriteLine(d == d);
            Console.WriteLine(p == p);

            Console.WriteLine("\n--- TESTS DE CASTEO ---");
            Console.WriteLine(((Dolar)e).GetCantidad());
            Console.WriteLine(((Pesos)e).GetCantidad());

            Console.WriteLine(((Euro)d).GetCantidad());
            Console.WriteLine(((Pesos)d).GetCantidad());

            Console.WriteLine(((Dolar)p).GetCantidad());
            Console.WriteLine(((Euro)p).GetCantidad());

            Console.WriteLine(((Euro)55).GetCantidad());
            Console.WriteLine(((Dolar)65).GetCantidad());
            Console.WriteLine(((Pesos)75).GetCantidad());

            Console.WriteLine("\n--- TESTS DE ADICION Y SUBSTRACCION ---");
            Console.WriteLine((p + p).GetCantidad());
            Console.WriteLine((p + d).GetCantidad());
            Console.WriteLine((p + e).GetCantidad());

            Console.WriteLine((d + d).GetCantidad());
            Console.WriteLine((d + p).GetCantidad());
            Console.WriteLine((d + e).GetCantidad());

            Console.WriteLine((e + e).GetCantidad());
            Console.WriteLine((e + d).GetCantidad());
            Console.WriteLine((e + p).GetCantidad());

            Console.Read();
        }
        public static Pesos operator -(Pesos p, Euro e)
        {
            Pesos peso = new Pesos();

            peso         = (Pesos)e;
            p._cantidad -= peso.getCantidad();
            return(p);
        }
Example #10
0
        public static Pesos operator -(Pesos p, Dolar d)
        {
            //Conversion de Euro a Dolar(¡)
            Pesos p1     = (Pesos)d;
            Pesos pFinal = new Pesos(p.GetCantidad() - p1.GetCantidad(), GetCotizacion());

            return(pFinal);
        }
Example #11
0
        static void Main(string[] args)
        {
            Dolar d1 = new Dolar(1);
            Pesos p1 = new Pesos(17.55d);

            Console.WriteLine(d1 == p1);
            Console.ReadLine();
        }
Example #12
0
 public static bool operator ==(Euro e, Pesos p)
 {
     if (e.GetCantidad() == ((p.GetCantidad() / Pesos.GetCotizacion()) / Euro.GetCotizacion()))
     {
         return(true);
     }
     return(false);
 }
        public static Pesos operator -(Pesos p, Dolar d)
        {
            Pesos peso = new Pesos();

            peso         = (Pesos)d;
            p._cantidad -= peso.getCantidad();
            return(p);
        }
Example #14
0
        public static bool operator ==(Pesos p, Euro e)
        {
            Pesos retorno = new Pesos();

            retorno = (Pesos)e;

            return(p.GetCantidad() == (float)retorno.GetCantidad());
        }
Example #15
0
 public static bool operator ==(Pesos p, Euro e)
 {
     if (p.GetCantidad() == ((e.GetCantidad() * Euro.GetCotizacion()) * Pesos.GetCotizacion()))
     {
         return(true);
     }
     return(false);
 }
Example #16
0
        public static Pesos operator -(Pesos p, Dolar d)
        {
            Pesos aux = new Pesos();

            aux = (Pesos)d;

            return(new Pesos(p.GetCantidad - aux.cantidad));
        }
Example #17
0
 public static bool operator ==(Dolar d, Pesos p)
 {
     if (d.GetCantidad() == (p.GetCantidad() / Pesos.GetCotizacion()))
     {
         return(true);
     }
     return(false);
 }
        public static Pesos operator +(Pesos p, Dolar d)
        {
            Pesos conversionPesos = new Pesos();

            conversionPesos = (Pesos)d;

            return(p.GetCantidad() + conversionPesos.GetCantidad());
        }
        public static Pesos operator +(Pesos p, Euro e)
        {
            Pesos conversionPesos = new Pesos();

            conversionPesos = (Pesos)e;

            return(e.GetCantidad() - conversionPesos.GetCantidad());
        }
Example #20
0
        public static Pesos operator -(Pesos p1, Pesos p2)
        {
            Pesos retorno = new Pesos();

            retorno = p1.GetCantidad() - p2.GetCantidad();

            return(retorno);
        }
        public static Pesos operator -(Pesos p, Dolar d)
        {
            Pesos conversionPesos = new Pesos(); //creo un objeto para poder convertir y operar

            conversionPesos = (Pesos)d;          //Conversión explícita a pesos

            //devuelvo el resultado de la resta
            return(p.GetCantidad() - conversionPesos.GetCantidad());
        }
Example #22
0
        public static bool operator !=(Dolar d, Pesos p)
        {
            Pesos dPesos = (Pesos)d;

            if (dPesos.GetCantidad() != d.GetCantidad())
            {
                return(true);
            }
            return(false);
        }
Example #23
0
        public static Pesos operator +(Pesos p, Dolar d)
        {
            double aux;

            aux = ((Pesos)d).cantidad;

            Pesos rta = new Pesos(p.cantidad + aux);

            return(rta);
        }
Example #24
0
        public static Pesos operator +(Pesos p, Euro e)
        {
            Pesos retorno = new Pesos();

            retorno = (Pesos)e;

            retorno = retorno.GetCantidad() + p.GetCantidad();

            return(retorno);
        }
Example #25
0
        public static Pesos operator -(Pesos p, Dolar d)
        {
            Pesos retorno = new Pesos();

            retorno = (Pesos)d;

            retorno = retorno.GetCantidad() - p.GetCantidad();

            return(retorno);
        }
Example #26
0
        public static Pesos operator -(Pesos p, Euro e)
        {
            double aux;

            aux = ((Pesos)e).cantidad;

            Pesos rta = new Pesos(p.cantidad - aux);

            return(rta);
        }
Example #27
0
 public static bool operator ==(Dolar d, Pesos p)
 {
     if (d._cantidad * Pesos.getCotizacion() == (float)p.getCantidad())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #28
0
 public static bool operator !=(Dolar d, Pesos p)
 {
     if (d.GetCantidad() == p.GetCantidad() * Pesos.GetCotizacion())
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #29
0
        public static bool operator ==(Pesos p, Euro e)
        {
            bool  ret = false;
            Pesos p2  = (Pesos)(e);

            if (p.GetCantidad() == p2.GetCantidad())
            {
                ret = true;
            }
            return(ret);
        }
Example #30
0
        public static bool operator !=(Pesos p, Euro e)
        {
            bool  returnValue = false;
            Pesos p1          = (Pesos)e;

            if (p.GetCantidad() != p1.GetCantidad())
            {
                returnValue = true;
            }
            return(returnValue);
        }