Beispiel #1
0
        public void agregar(ClaseBaseCaja nuevo)
        {
            ClaseBaseCaja temp = inicio;

            if (inicio == null)
            {
                inicio = nuevo;
                ultimo = nuevo;
            }
            else if (nuevo.caja < inicio.caja)
            {
                nuevo.Siguiente = inicio;
                inicio.Anterior = nuevo;
                inicio          = nuevo;
            }
            else if (nuevo.caja > ultimo.caja)
            {
                ultimo.Siguiente = nuevo;
                nuevo.Anterior   = nuevo;
                ultimo           = nuevo;
            }
            else
            {
                while (nuevo.caja > temp.caja)
                {
                    temp = temp.Siguiente;
                }

                nuevo.Anterior          = temp.Anterior;
                nuevo.Siguiente         = temp;
                temp.Anterior.Siguiente = nuevo;
                temp.Anterior           = nuevo;
            }
        }
Beispiel #2
0
        private void btnComenzar_Click(object sender, EventArgs e)
        {
            int cont = 1;

            while (activas != null)
            {
                cont++;

                activas = activas.Siguiente;
            }
            activas = new ClaseBaseCaja(cont);
            cajas.agregar(activas);

            for (int i = 1; i <= 300; i++)
            {
                int r = prob.Next(1, 101);

                if (r <= 40)
                {
                    if (activas.PersonasAtendiendo == 4)
                    {
                        activas = activas.Siguiente;
                    }
                    else
                    {
                        p = new ClaseBasePersonas();
                        c.push(p);
                    }

                    if (activas.Siguiente == null)
                    {
                        activas = new ClaseBaseCaja(1);
                        cajas.agregar(activas);
                    }
                }
                if (c.peek()._ciclos > 0)
                {
                    c.peek()._ciclos--;

                    if (c.peek()._ciclos == 0)
                    {
                        c.pop();
                    }
                }
            }
        }