Exemple #1
0
 public void consultar(Semilla s, Granja g)
 {
     try
     {
         Semilla s1 = g.almacenOfi.semillasGuardas.First(s2 => s2.id == s.id) as Semilla;
         Semilla s2 = g.terrenoOfi.listSemillas.First(s3 => s3.id == s.id) as Semilla;
         Semilla s3 = g.terrenoOfi.listSemillas.First(s4 => s4.id == s.id) as Semilla;
         Console.WriteLine("El tipo de semilla es:", s.tipo);
         Console.WriteLine("La cantidad de agua que necesita es:", s.cantAgua);
         Console.WriteLine("La semilla en este momento se encuentra recibiendo:", s.sombra);
         Console.WriteLine("Su tamaño actual es: ", s.size);
         if (s1 != null)
         {
             Console.WriteLine("Se encuentra en el Almacen");
         }
         if (s2 != null)
         {
             Console.WriteLine("Se encuentra en el Terreno");
         }
         if (s3 != null)
         {
             Console.WriteLine("Se encuentra en el planB");
         }
     }
     catch (ArgumentNullException ex)
     {
         throw ex;
     }
 }
Exemple #2
0
        public void techo(Semilla s, Granja g)
        {
            Semilla s1 = g.terrenoOfi.listSemillas.Find(s11 => s11.id == s.id) as Semilla;
            Semilla s2 = g.terrenoOfi.planB.listSemillas.Find(s22 => s22.id == s.id) as Semilla;

            if (s1 != null && s2 == null)
            {
                if (s1.sombra == false)
                {
                    s1.sombra = true;
                }
                else
                {
                    s1.sombra = false;
                }
            }
            else if (s2 != null && s1 == null)
            {
                if (s2.sombra == false)
                {
                    s2.sombra = true;
                }
                else
                {
                    s2.sombra = false;
                }
            }
            else
            {
                Console.WriteLine(alarma("No se encuentra la semilla "));
            }
        }
Exemple #3
0
        public void riego(Semilla s, Granja g)
        {
            Semilla s1 = g.terrenoOfi.listSemillas.Find(s11 => s11.id == s.id) as Semilla;
            Semilla s2 = g.terrenoOfi.planB.listSemillas.Find(s22 => s22.id == s.id) as Semilla;

            if (s1 != null)
            {
                if (s1.cantAgua <= 3)
                {
                    s1.cantAgua++;
                }
                else
                {
                    s1.cantAgua = 0;
                    Console.WriteLine("La semilla ya ha sido regada lo suficiente.");
                }
            }
            else if (s2 != null)
            {
                if (s2.cantAgua <= 3)
                {
                    s2.cantAgua++;
                }
                else
                {
                    s2.cantAgua = 0;
                    Console.WriteLine("La semilla ya ha sido regada lo suficiente.");
                }
            }
            else
            {
                Console.WriteLine(alarma("No se encuentra la semilla "));
            }
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var Services = scope.ServiceProvider;
                try{
                    var context = Services.GetRequiredService <DataContext>();
                    context.Database.Migrate();
                    Semilla.SemillaUsuario(context);
                }catch (Exception ex)
                {
                    var logger = Services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "Ocurrio un error durante la migracion");
                }
            }
            host.Run();
        }
Exemple #5
0
        public void plantar(Semilla s, Granja g)
        {
            Semilla s1 = g.almacenOfi.semillasGuardas.Find(s11 => s11.id == s.id) as Semilla;

            if (s1 != null)
            {
                if (g.terrenoOfi.validador == false)
                {
                    g.terrenoOfi.listSemillas.Add(s1);
                    g.terrenoOfi.estadoTerreno++;
                    g.almacenOfi.semillasGuardas.Remove(s1);
                }
                else
                {
                    g.terrenoOfi.planB.listSemillas.Add(s1);
                    g.terrenoOfi.planB.estadoTerreno++;
                    g.almacenOfi.semillasGuardas.Remove(s1);
                }
            }
            else
            {
                Console.WriteLine(alarma("No se encuentra la semilla "));
            }
        }
 private void DataGridView_Principal_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (!e.Alt && !e.Control && !e.Shift)
         {
             if (e.KeyCode == Keys.Escape)
             {
                 e.Handled          = true;
                 e.SuppressKeyPress = true;
                 this.Close();
             }
             else if (e.KeyCode == Keys.Enter)
             {
                 e.Handled          = true;
                 e.SuppressKeyPress = true;
                 if (DataGridView_Principal.SelectedRows != null && DataGridView_Principal.SelectedRows.Count > 0)
                 {
                     Program.Crear_Carpetas(Ruta_Mapas);
                     int Valor = (byte)DataGridView_Principal.SelectedRows[0].Cells[Columna_Último_Byte.Index].Value;
                     for (int Índice = 0; Índice < PixARK_Seeds.Lista_Semilas_Parecidas.Count; Índice++)
                     {
                         try
                         {
                             if (PixARK_Seeds.Lista_Semilas_Parecidas[Índice].Key == Valor)
                             {
                                 foreach (int Semilla in PixARK_Seeds.Lista_Semilas_Parecidas[Índice].Value)
                                 {
                                     try
                                     {
                                         Program.Ejecutar_Ruta(Ruta_Mapas + "\\" + Semilla.ToString() + ".png", ProcessWindowStyle.Maximized);
                                     }
                                     catch (Exception Excepción) { Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null); Variable_Excepción_Total++; Variable_Excepción = true; continue; }
                                 }
                                 break;
                             }
                         }
                         catch (Exception Excepción) { Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null); Variable_Excepción_Total++; Variable_Excepción = true; continue; }
                     }
                 }
             }
         }
     }
     catch (Exception Excepción) { Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null); Variable_Excepción_Total++; Variable_Excepción = true; }
 }
Exemple #7
0
        private void button7_Click(object sender, EventArgs e)
        {
            //METODO CONGRUENCIAL MULTIPLICATIVO

            double Semilla, k, Modulo, N, g, a;

            Semilla = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("Ingrese la semilla:", "Semila", "0", 100, 100));
            k       = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("Ingrese el valor de k:", "Semila", "0", 100, 100));
            g       = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("Ingrese el valor de g:", "Semila", "0", 100, 100));
            Modulo  = Math.Pow(2, g);
            N       = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("¿Cuantos numeros desea generar?:", "Numeros a generar", "0", 100, 100));

            a = (5 + (8 * k));

            //txtModuloCongMulti.Text = (Modulo.ToString());

            for (int i = 1; i < N; i++)
            {
                Semilla = (a * Semilla) % Modulo;
                listMostrarCompleto.Items.Add(Semilla);
                double nuevo2 = (Semilla / (Modulo - 1));

                string semillaText = Semilla.ToString();

                int tamanotexto = nuevo2.ToString().Length;

                semillaText = semillaText.Substring(0, 4);

                listMostrarCentrales.Items.Add("0." + nuevo2);
            }

            //------------------------------------------------------------------------------

            double promedio = 0;
            double suma     = 0;

            foreach (object item in listMostrarCentrales.Items) //SUMA TODOS LOS NUMEROS ALEATORIOS GENERADOS
            {
                suma += Convert.ToDouble(item);
            }

            promedio = suma / N;

            //-----------------------------------------------------------------------------

            double nuevo = 0;
            double resta = 0;

            foreach (object item in listMostrarCentrales.Items) //SUMA TODOS LOS NUMEROS ALEATORIOS GENERADOS - PROMEDIO
            {
                resta += Convert.ToDouble(item);                //Y ELEVA AL CUADRAO

                nuevo = Math.Pow((resta - promedio), 2);
            }

            double nuevaSumatoria = nuevo;

            //--------------------------------------------------------------------------------

            txtPromedio.Text = (promedio.ToString());  //IMPRIME EL PROMEDIO

            double ValorEsperado = 0.05;               //ES EL VALOR ESPERADO

            double Alfa = ((1 - (ValorEsperado / 2))); //ELEMENTO NESESARIO PARA LIMITES

            txtAlfa.Text = Alfa.ToString();

            double Z = 0.95996398;

            txtZ.Text = (Z.ToString());

            double LimSuperior = ((ValorEsperado - Z) * (1 / Math.Sqrt(12 * N)));

            txtLimSuperior.Text = (LimSuperior.ToString());

            double LimInferior = ((ValorEsperado + Z) * (1 / Math.Sqrt(12 * N)));

            txtLimInferior.Text = (LimInferior.ToString());

            //--------------------------------------------------------------------------------------

            //FORMULA DE LA VARIANZA

            double varianza = (nuevo / N - 1);

            txtVarianza.Text = (varianza.ToString());
        }
Exemple #8
0
        private void btnCongruencialMultiplicativo_Click(object sender, EventArgs e)
        {
            //METODO CONGRUENCIAL MULTIPLICATIVO

            double Semilla, k, Modulo, N, g, a, numintervalos;

            numintervalos = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("¿Cuantos intervalos desea?:", "Dados", "0", 100, 100));
            Semilla       = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("Ingrese la semilla:", "Semila", "0", 100, 100));
            k             = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("Ingrese el valor de k:", "Semila", "0", 100, 100));
            g             = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("Ingrese el valor de g:", "Semila", "0", 100, 100));
            Modulo        = Math.Pow(2, g);
            N             = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("¿Cuantos numeros desea generar?:", "Numeros a generar", "0", 100, 100));

            a = (5 + (8 * k));

            double valorintervalo = (1 / numintervalos);

            for (int i = 1; i < N; i++)
            {
                Semilla = (a * Semilla) % Modulo;
                double nuevo2      = (Semilla / (Modulo - 1));
                string semillaText = Semilla.ToString();
                int    tamanotexto = nuevo2.ToString().Length;
                semillaText = semillaText.Substring(0, 4);
                listNumGene.Items.Add("0." + nuevo2);
            }

            foreach (object item in listNumGene.Items)
            {
                //Asignacion de valores a intervalos

                if (Convert.ToDouble(item) < valorintervalo)
                {
                    listInter1.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 2) && Convert.ToDouble(item) > valorintervalo)
                {
                    listInter2.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 3) && Convert.ToDouble(item) > (valorintervalo * 2))
                {
                    listInter3.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 4) && Convert.ToDouble(item) > (valorintervalo * 3))
                {
                    listInter4.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 5) && Convert.ToDouble(item) > (valorintervalo * 4))
                {
                    listInter5.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 6) && Convert.ToDouble(item) > (valorintervalo * 5))
                {
                    listInter6.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 7) && Convert.ToDouble(item) > (valorintervalo * 6))
                {
                    listInter7.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 8) && Convert.ToDouble(item) > (valorintervalo * 7))
                {
                    listInter8.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 9) && Convert.ToDouble(item) > (valorintervalo * 8))
                {
                    listInter9.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 10) && Convert.ToDouble(item) > (valorintervalo * 9))
                {
                    listInter10.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 11) && Convert.ToDouble(item) > (valorintervalo * 10))
                {
                    listInter11.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 12) && Convert.ToDouble(item) > (valorintervalo * 13))
                {
                    listInter12.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 14) && Convert.ToDouble(item) > (valorintervalo * 15))
                {
                    listInter13.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 15) && Convert.ToDouble(item) > (valorintervalo * 16))
                {
                    listInter14.Items.Add(Convert.ToDouble(item));
                }
                else if (Convert.ToDouble(item) < (valorintervalo * 16) && Convert.ToDouble(item) > (valorintervalo * 17))
                {
                    listInter15.Items.Add(Convert.ToDouble(item));
                }
            }
        }