static void Main(string[] args) { #region Attributes string centralitaPath = $"{Environment.CurrentDirectory}"; string centralitaFileName = "Bitacora"; #endregion #region Instances Centralita c = new Centralita("Fede Center"); Local l1 = new Local("Bernal", "Rosario", 33, (float)2.85); Provincial l2 = new Provincial(29, "Morón", "Bernal", Provincial.Franja.Franja_01); Local l3 = new Local("Lanús", "San Rafael", 55, 1.98f); Provincial l4 = new Provincial(l2, Provincial.Franja.Franja_03); #endregion // Las llamadas se irán registrando en la Centralita. // La centralita mostrará por pantalla todas las llamadas según las vaya registrando. try { c += l1; c.Guardar(centralitaPath, centralitaFileName); l1.Guardar(centralitaPath, l1); c += l2; c.Guardar(centralitaPath, centralitaFileName); l2.Guardar(centralitaPath, l2); c += l3; c.Guardar(centralitaPath, centralitaFileName); l3.Guardar(centralitaPath, l3); c += l4; c.Guardar(centralitaPath, centralitaFileName); l4.Guardar(centralitaPath, l4); c += l4; // Duplicado } catch (CentralitaException ce) { Console.WriteLine($"Error: {ce.Message} producido en {ce.NombreClase} al usar {ce.NombreMetodo}."); } catch (FallaLogException fl) { Console.WriteLine($"Error: {fl.Message} producido en {fl.NombreClase} al usar {fl.NombreMetodo}."); } c.OrdenarLlamadas(); Console.WriteLine(c.ToString()); Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("_________________________________"); Console.WriteLine(c.Leer()); Console.ReadKey(); }
private void btnLlamar_Click(object sender, EventArgs e) { string numOrigen; string numDestino; float costo; Random tiempoRandom = new Random(); Provincial <string> .Franja franja; costo = (float)(tiempoRandom.Next(5, 56) / 10f); //0,5 y 5,6 float tiempo = tiempoRandom.Next(1, 50); numOrigen = this.txtNroOrigen.Text; numDestino = this.txtNroDestino.Text; Enum.TryParse <Provincial <string> .Franja>(this.cmbFranja.SelectedValue.ToString(), out franja); try { if (numDestino != "" && numDestino.ToList()[0] == '#') { this.centralita = this.centralita + new Provincial <string>(numOrigen, franja, tiempo, numDestino); } else { this.centralita = this.centralita + new Local <string>(numOrigen, tiempo, numDestino, costo); } centralita.Guardar(); } catch (CentralitaException cE) { MessageBox.Show(cE.Message); } }
static void Main(string[] args) { // Mi central Centralita c = new Centralita("Fede Center"); Console.WriteLine(c.Llamadas); // Mis 4 llamadas Local l1 = new Local("Bernal", 30, "Rosario", 2.65f); Provincial l2 = new Provincial("Morón", Franja.Franja_1, 21, "Bernal"); Local l3 = new Local("Lanús", 45, "San Rafael", 1.99f); Provincial l4 = new Provincial(Franja.Franja_3, l2); // Las llamadas se irán registrando en la Centralita. // La centralita mostrará por pantalla todas las llamadas según las vaya registrando. c += l1; c += l2; c += l3; // El operador debería detectar que es la misma llamada que l2 y por lo tanto no agregarla a la centralita. try { c += l4; } catch (CentralitaException ex) { Console.WriteLine(ex.Message); } // Ordeno las llamadas c.OrdenarLlamadas(); // Muestro... Console.WriteLine(c.ToString()); // Guardo el registro de llamadas en un archivo de texto, lo leo y lo muestro por pantalla try { c.Guardar(); } catch (FallaLogException ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine(c.Leer()); } Console.ReadKey(); }
static void Main(string[] args) { //Console.WriteLine(nombreArchivo); //Console.ReadKey(); // Mi central Centralita c = new Centralita("Fede Center"); // Mis 4 llamadas Local l1 = new Local("Bernal", 30, "Rosario", 2.65f); Provincial l2 = new Provincial("Morón", Provincial.Franja.Franja_1, 21, "Bernal"); Local l3 = new Local("Lanús", 45, "San Rafael", 1.99f); Provincial l4 = new Provincial(Provincial.Franja.Franja_3, l2); Local sergio = new Local(); // Las llamadas se irán registrando en la Centralita. c.RutaDeArchivo = "Log de llamadas"; try { c = c + l1; c = c + l2; c = c + l3; c = c + l4; } catch (CentralitaException e) { Console.WriteLine(e.Message); } c.OrdenarLlamadas(); l1.Guardar(); l2.Guardar(); c.Guardar(); Console.ReadKey(); Console.WriteLine(l1.Leer()); Console.ReadKey(); Console.WriteLine(l2.Leer()); Console.ReadKey(); Console.WriteLine(c.Leer()); LocalDAO a = new LocalDAO(); a.Guardar(l3); Console.ReadKey(); }
static void Main(string[] args) { // Mi central Centralita c = new Centralita("Cin Center"); // Mis 4 llamadas Local l1 = new Local("Bernal", 30, "Rosario", 2.65f); Provincial l2 = new Provincial(Provincial.Franja.Franja_1, "Morón", 21, "Bernal"); Local l3 = new Local("Lanús", 45, "San Rafael", 1.99f); Provincial l4 = new Provincial(Provincial.Franja.Franja_3, "Avellaneda", 12, "Quilmes"); Llamada l5 = new Provincial(Provincial.Franja.Franja_3, "Avellaneda", 12, "Quilmes"); // Las llamadas se irán registrando en la Centralita. // La centralita mostrará por pantalla todas las llamadas según las vaya registrando. try { c += l1; c += l2; c += l3; c += l4; c += l5; c.OrdenarLlamadas(); Console.WriteLine(c.ToString()); } catch (CentralitaException e) { c.Guardar(); Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } Console.ReadKey(); }