Ejemplo n.º 1
0
        private void buConfirmarCompra_Click(object sender, EventArgs e)
        {
            string _nombre   = textBoxNombre.Text;
            string _apellido = textBoxApellido.Text;
            //string _asiento = textBoxAsiento.Text;
            string          _edad = textBoxEdad.Text;
            List <Pasajero> listapasajeroVuelo = new List <Pasajero>();

            for (int x = 0; x < listaVuelosElegidos.Count; x++)
            {
                for (int i = 0; i < listaVuelos.Count; i++)
                {
                    if (listaVuelosElegidos[x].getOrigen() == listaVuelos[i].getOrigen() && listaVuelosElegidos[x].getDestino() == listaVuelos[i].getDestino())
                    {
                        VentanaAsientos VAsientos = new VentanaAsientos(ref listaVuelos, i);
                        VAsientos.ShowDialog();
                        int _asiento = VAsientos.getAsiento();
                        //Console.WriteLine("entro papuuuuu");

                        Pasajero p = new Pasajero(_nombre, _apellido, _edad, _asiento.ToString(), listaVuelos[i].getRuta());
                        registro = true;
                        listaVuelos[i].asientos[_asiento - 1] = false;
                        listaVuelos[i].asientosDisponibles--;
                        listaVuelos[i].setPasajero(p);
                        listapasajeroVuelo.Add(p);
                    }
                }
            }

            this.Close();
            Confirmacion Mconfirmacion = new Confirmacion(ref listapasajeroVuelo, _costo);

            Mconfirmacion.ShowDialog();
        }
Ejemplo n.º 2
0
        private void swapToPasajeros(int i, int j)
        {
            Pasajero aux = new Pasajero();

            aux = this.listaPasajeros[i];
            this.listaPasajeros[i] = this.listaPasajeros[j];
            this.listaPasajeros[j] = aux;
        }
 public Confirmacion(Pasajero pa, string asiento)
 {
     this.asiento = asiento;
     this.p       = pa;
     InitializeComponent();
     labelasientoConf.Text        = "ASIENTO: " + asiento;
     labelEdad.Text               = "EDAD: " + pa.getEdad();
     labelVueloVconfirmacion.Text = "VUELO: " + pa.getVuelo();
     labelNombreVconfi.Text       = "NOMBRE: " + pa.getNombre();
 }
Ejemplo n.º 4
0
 //ORDENAR
 public int compareTo(Pasajero a, Pasajero b, int opc)
 {
     if (opc == 0)
     {
         if (string.Compare(a.getNombre(), b.getNombre()) == 1)//Mayor a.getNombre() > b.getNombre()
         {
             return(1);
         }
         if (string.Compare(b.getNombre(), a.getNombre()) == 1)//MEnor a.getNombre() > b.getNombre()
         {
             return(-1);
         }
     }
     if (opc == 1)
     {
         if (string.Compare(a.getVuelo(), b.getVuelo()) == 1)
         {
             return(1);
         }
         if (string.Compare(b.getVuelo(), a.getVuelo()) == 1)
         {
             return(-1);
         }
     }
     if (opc == 2)
     {
         if (string.Compare(a.getEdad(), b.getEdad()) == 1)
         {
             return(1);
         }
         if (string.Compare(b.getEdad(), a.getEdad()) == 1)
         {
             return(-1);
         }
     }
     if (opc == 3)
     {
         if (b.getAsientoInt() < a.getAsientoInt())
         {
             return(1);
         }
         if (b.getAsientoInt() > a.getAsientoInt())
         {
             return(-1);
         }
     }
     return(0);
 }
        private void buConfirmarCompra_Click(object sender, EventArgs e)
        {
            string _nombre   = textBoxNombre.Text;
            string _apellido = textBoxApellido.Text;
            string _asiento  = textBoxAsiento.Text;
            string _edad     = textBoxEdad.Text;
            string _vuelo    = labelMuestraVuelo.Text;


            Pasajero p = new Pasajero(_nombre, _apellido, _edad, _asiento, _vuelo);

            registro = true;
            listaVuelos[ind].asientos[Int32.Parse(textBoxAsiento.Text) - 1] = false;
            textBoxAsiento.Enabled = false;
            listaVuelos[ind].asientosDisponibles--;
            listaVuelos[ind].setPasajero(p);

            Confirmacion Mconfirmacion = new Confirmacion(p, _asiento);

            Mconfirmacion.ShowDialog();

            this.Close();
        }
Ejemplo n.º 6
0
        public void quickSort(int inicio, int final, int _opc)
        {
            int      i      = inicio;
            int      j      = final;
            int      medio  = (inicio + final) / 2;
            Pasajero pivote = new Pasajero();

            pivote = listaPasajeros[medio];

            do
            {
                while (compareTo(listaPasajeros[i], pivote, _opc) == -1)
                {
                    i++;
                }
                while (compareTo(listaPasajeros[j], pivote, _opc) == 1)
                {
                    j--;
                }

                if (i <= j)
                {
                    swapToPasajeros(i, j);
                    i++;
                    j--;
                }
            } while (i <= j);

            if (i < final)
            {
                quickSort(i, final, _opc);
            }
            if (j > inicio)
            {
                quickSort(inicio, j, _opc);
            }
        }
Ejemplo n.º 7
0
 public void setPasajero(Pasajero v)
 {
     this.listaPasajeros.Add(v);
 }