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(); }
public static bool operator ==(Dolar d, Pesos p) { if (d.GetCantidad() == (p.GetCantidad() / Pesos.GetCotizacion())) { return(true); } return(false); }
public static bool operator ==(Pesos p, Euro e) { if (p.GetCantidad() == ((e.GetCantidad() * Euro.GetCotizacion()) * Pesos.GetCotizacion())) { return(true); } return(false); }
public static bool operator ==(Euro e, Pesos p) { if (e.GetCantidad() == ((p.GetCantidad() / Pesos.GetCotizacion()) / Euro.GetCotizacion())) { return(true); } return(false); }
public static bool operator !=(Dolar d, Pesos p) { if (d.GetCantidad() == p.GetCantidad() * Pesos.GetCotizacion()) { return(false); } else { return(true); } }
static void Main(string[] args) { Console.Title = "Ejercicio Nro 20"; //Builder with one parametre Dolar dolar1 = new Dolar(2000); Euro euro1 = new Euro(1000); Pesos peso1 = new Pesos(10000); //Builder with two parametres Dolar dolar2 = new Dolar(1000, 1); Euro euro2 = new Euro(500, 1.16f); Pesos peso2 = new Pesos(5000, 38.33f); //Builder with one parametre Dolar dolar3 = new Dolar(1500); Euro euro3 = new Euro(500); Pesos peso3 = new Pesos(2000); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Cotizaciones del Dia Respecto al DOLAR U$D: \nEuro: ${0} Peso: ${1}", euro1.GetCotizacion(), peso1.GetCotizacion()); Console.WriteLine("Cotizaciones del Dia Respecto al DOLAR U$D: \nEuro: ${0} Peso: ${1}\n", euro2.GetCotizacion(), peso2.GetCotizacion()); //Explicit Casting euro1 = (Euro)dolar1; peso1 = (Pesos)dolar1; Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Mi Cuenta 1: Tiene ${0} Dolares = ${1,5:#,###.00} Euros - ${2,5:#,###.00} Pesos", dolar1.GetCantidad(), euro1.GetCantidad(), peso1.GetCantidad()); //Explicit Casting //dolar2 = (Dolar)peso2; //euro2 = (Euro)peso2; Console.WriteLine("Mi Cuenta 2: Tiene ${0,5:#,###.00} Dolares = ${1,5:#,###.00} Euros - ${2,5:#,###.00} Pesos", dolar2.GetCantidad(), euro2.GetCantidad(), peso2.GetCantidad()); Console.WriteLine("Mi Cuenta 3: Tiene ${0,5:#,###.00} Dolares = ${1,5:#,###.00} Euros - ${2,5:#,###.00} Pesos", dolar3.GetCantidad(), euro3.GetCantidad(), peso3.GetCantidad()); //OverLoad of operators Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nEntre mis cuentas 2 y 3 tengo:\nDistintos Dolares {0} \nIgual Euros {1}\nIgual Pesos {2}", (dolar2 != dolar3), (euro2 == euro3), (peso2 == peso3)); Console.ReadKey(); }
public static Pesos operator +(Pesos p, Euro e) { Pesos aux = new Pesos(p.GetCantidad() + (e.GetCantidad() * Euro.GetCotizacion() * Pesos.GetCotizacion())); return(aux); }
public static bool operator ==(Dolar d, Pesos p) { return(d.cantidad == (p.GetCantidad() / Pesos.GetCotizacion())); }
public static Dolar operator +(Dolar d, Pesos p) { return(new Dolar(d.cantidad + (p.GetCantidad() / Pesos.GetCotizacion()))); }
public static Euro operator -(Euro e, Pesos p) { return(new Euro(e.cantidad - (p.GetCantidad() / Pesos.GetCotizacion()))); }
public static Pesos operator +(Pesos p, Dolar d) { Pesos aux = new Pesos((Dolar.ConvertToDolar(p) + d.GetCantidad()) * Pesos.GetCotizacion()); return(aux); }
public static Euro operator +(Euro e, Pesos p) { return(new Euro(((e.GetCantidad() / Euro.GetCotizacion()) + (p.GetCantidad() / Pesos.GetCotizacion())) * GetCotizacion())); }
public static Dolar operator +(Dolar d, Pesos p) { Dolar aux = new Dolar(d.GetCantidad() + (p.GetCantidad() / Pesos.GetCotizacion())); return(aux); }
public static Pesos operator -(Pesos p, Euro e) { return(new Pesos(p.GetCantidad() - (e.GetCantidad() * Euro.GetCotizacion() * Pesos.GetCotizacion()))); }
public static double ConvertToDolar(Pesos p) { double pesosToDolar = p.GetCantidad() / Pesos.GetCotizacion(); return(pesosToDolar); }
public static Pesos operator +(Pesos p, Euro e) { Pesos aux = new Pesos((Dolar.ConvertToDolar(e) + Dolar.ConvertToDolar(p)) * Pesos.GetCotizacion()); return(aux); }
public static Pesos operator -(Pesos p, Dolar d) { Pesos aux = new Pesos(p.GetCantidad() - (d.GetCantidad() * Pesos.GetCotizacion())); return(aux); }
public static bool operator ==(Euro e, Pesos p) { return(e.cantidad / GetCotizacion() == p.GetCantidad() / Pesos.GetCotizacion()); }