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 p1, Pesos p2) { bool distinto = false; if (p1.GetCantidad() != p2.GetCantidad()) { distinto = true; } return(distinto); }
public static Pesos operator +(Pesos p, Euro e) { Pesos p1 = (Pesos)e; Pesos pFinal = new Pesos(p.GetCantidad() + p1.GetCantidad(), GetCotizacion()); return(pFinal); }
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); }
public static bool operator ==(Pesos p, Euro e) { Pesos retorno = new Pesos(); retorno = (Pesos)e; return(p.GetCantidad() == (float)retorno.GetCantidad()); }
public static Pesos operator +(Pesos p, Euro e) { Pesos conversionPesos = new Pesos(); conversionPesos = (Pesos)e; return(e.GetCantidad() - conversionPesos.GetCantidad()); }
public static Pesos operator +(Pesos p, Dolar d) { Pesos conversionPesos = new Pesos(); conversionPesos = (Pesos)d; return(p.GetCantidad() + conversionPesos.GetCantidad()); }
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 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()); }
public static Pesos operator +(Pesos p, Euro e) { Pesos retorno = new Pesos(); retorno = (Pesos)e; retorno = retorno.GetCantidad() + p.GetCantidad(); return(retorno); }
public static Pesos operator -(Pesos p, Dolar d) { Pesos retorno = new Pesos(); retorno = (Pesos)d; retorno = retorno.GetCantidad() - p.GetCantidad(); return(retorno); }
public static bool operator !=(Dolar d, Pesos p) { Pesos dPesos = (Pesos)d; if (dPesos.GetCantidad() != d.GetCantidad()) { return(true); } return(false); }
public static bool operator ==(Pesos p, Euro e) { bool ret = false; Pesos p2 = (Pesos)(e); if (p.GetCantidad() == p2.GetCantidad()) { ret = true; } return(ret); }
public static bool operator !=(Dolar d, Euro e) { if (d.GetCantidad() == e.GetCantidad() * Euro.GetCotizacion()) { return(false); } else { return(true); } }
public static bool operator !=(Pesos p, Euro e) { bool returnValue = false; Pesos p1 = (Pesos)e; if (p.GetCantidad() != p1.GetCantidad()) { returnValue = true; } return(returnValue); }
public static bool operator ==(Dolar d, Pesos p) { Pesos auxP = (Pesos)d; if (auxP.GetCantidad() == p.GetCantidad()) { return(true); } else { return(false); } }
public static bool operator !=(Pesos p, Dolar d) { Pesos p1 = (Pesos)d; bool returnValue = false; //Console.WriteLine("Holaaa"); //Console.ReadKey(); if (p.GetCantidad() != p1.GetCantidad()) { returnValue = true; } return(returnValue); }
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(); }
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(); }
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(); }
public static double ConvertToDolar(Pesos p) { double pesosToDolar = p.GetCantidad() / Pesos.GetCotizacion(); return(pesosToDolar); }