static void Main(string[] args) { Euro euro1 = 20d; Dolar dolar1 = 15d; Pesos pesos1 = 50d; Console.WriteLine(euro1.GetCantidad()); Console.WriteLine(dolar1.GetCantidad()); Console.WriteLine(pesos1.GetCantidad()); Euro e = new Euro(10); Dolar d = new Dolar(10); Pesos p = new Pesos(10); d = (Dolar)e; Console.WriteLine(d.GetCantidad()); Euro aux_e = e + d; Console.WriteLine("Euro + Dólar: {0}", aux_e.GetCantidad()); aux_e = e + p; Console.WriteLine("Euro + Pesos: {0}", aux_e.GetCantidad()); Console.WriteLine("----------------------------------------------"); Dolar aux_d = d + e; Console.WriteLine("Dólar + Euro: {0}", aux_d.GetCantidad()); aux_d = d + p; Console.WriteLine("Dólar + Pesos: {0}", aux_d.GetCantidad()); Console.WriteLine("----------------------------------------------"); Pesos aux_p = p + e; Console.WriteLine("Pesos + Euro: {0}", aux_p.GetCantidad()); aux_p = p + d; Console.WriteLine("Pesos + Dólar {0}", aux_p.GetCantidad()); Console.ReadKey(); }
public static Dolar operator+(Dolar d, Euro e) { Dolar dolar = new Dolar(d.GetCantidad() + ((Dolar)e).GetCantidad()); return(dolar); }
public static Pesos operator +(Pesos p, Dolar d) { Dolar d2 = (Dolar)(p); return((Pesos)(new Dolar(d.GetCantidad() + d2.GetCantidad()))); }
public static Dolar operator +(Dolar d, Pesos p) { Dolar d2 = (Dolar)(p); return(new Dolar(d.GetCantidad() + d2.GetCantidad())); }
public static Dolar operator +(Dolar d, Euro e) { Dolar d2 = (Dolar)(e); return(new Dolar(d.GetCantidad() + d2.GetCantidad())); }
public static bool operator ==(Pesos p, Dolar d) { return(((Dolar)p).GetCantidad() == d.GetCantidad()); }
public static bool operator==(Dolar d, Pesos p) { Dolar dAux = (Dolar)p; return(d.GetCantidad() == dAux.GetCantidad()); }
public static bool operator ==(Dolar d, Euro e) { Dolar dAux = (Dolar)e; return(d.GetCantidad() == dAux.GetCantidad()); }
public static bool operator ==(Dolar d, Euro e) { Dolar retorno = (Dolar)e; return((float)d.GetCantidad() == retorno.GetCantidad()); }
public static Euro operator +(Euro e, Dolar d) { Dolar d2 = (Dolar)(e); return((Euro)(new Dolar(d.GetCantidad() + d2.GetCantidad()))); }
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(); }