コード例 #1
0
ファイル: Bodega.cs プロジェクト: amaya2001/PracticaPoo1
        public void addSemilla(Semilla semilla)
        {
            Semilla[] ListaSemillastemp = new Semilla[ListaSemillas.Length];
            this.ListaSemillas[ListaSemillas.Length - 1] = semilla;
            int i;

            for (i = 0; i < ListaSemillas.Length; i++)
            {
                ListaSemillastemp[i] = this.ListaSemillas[i];
                Console.WriteLine("i" + i);
            }
            this.ListaSemillas = new Semilla[ListaSemillastemp.Length + 1];
            int j;

            for (j = 0; j < ListaSemillastemp.Length; j++)
            {
                this.ListaSemillas[j] = ListaSemillastemp[j];
            }
        }
コード例 #2
0
        public void RegarSemillas()
        {
            bool   continuar = true;
            string mensaje   = "";

            do
            {
                try
                {
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("----- Sistema de Riego de Semillas Bodega: " + bodega.Nombre + " ------");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("----------- Menu  ----------");
                    Console.WriteLine("1 Regar Una semilla");
                    Console.WriteLine("2 Regar Todas las Semillas");
                    Console.WriteLine("3 Regresar");
                    Console.WriteLine("----------- Menu  ----------");
                    Console.WriteLine(" ID | Tipo | Cantidad Agua | Cantidad Sombra");
                    Semilla[] ListaSemillas = bodega.getListSemillas();
                    int       i;
                    for (i = 0; i < ListaSemillas.Length - 1; i++)
                    {
                        Console.WriteLine(" " + ListaSemillas[i].Id + " | " + ListaSemillas[i].Tipo + " | " + ListaSemillas[i].CantidadAgua + " | " + ListaSemillas[i].CantidadSombra);
                    }
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(mensaje);
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("Digite una opcion: ");
                    string opc = Console.ReadLine();
                    switch (opc)
                    {
                    case "1":
                        Console.Write("Digita el Id de la semilla: ");
                        int     id      = int.Parse(Console.ReadLine());
                        Semilla semilla = ListaSemillas[id - 1];
                        Console.WriteLine("Semilla Seleccionada: " + semilla.Tipo);
                        Console.WriteLine("Iniciar Proceso de Riego, cantiad de agua: " + semilla.CantidadAgua + "lts");
                        Console.ForegroundColor = ConsoleColor.Green;
                        for (int j = 0; j < semilla.CantidadAgua; j++)
                        {
                            Console.Write("**");
                            Thread.Sleep(400);
                        }
                        mensaje = "[ Semilla " + semilla.Tipo + " Regada Completamente ]";
                        break;

                    case "2":
                        Console.WriteLine("Iniciar Proceso de Riego, Todas las semillas serán regadas");

                        for (int z = 0; z < bodega.getListSemillas().Length - 1; z++)
                        {
                            Console.WriteLine("Semilla: " + bodega.getListSemillas()[z].Tipo);
                            Console.WriteLine("Iniciar Proceso de Riego, cantiad de agua: " + bodega.getListSemillas()[z].CantidadAgua + "lts");
                            Console.ForegroundColor = ConsoleColor.Green;
                            for (int j = 0; j < bodega.getListSemillas()[z].CantidadAgua; j++)
                            {
                                Console.Write("**");
                                Thread.Sleep(400);
                            }
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.WriteLine();
                        }

                        mensaje = "[ Todas las semillas fueron regadas completamente ]";
                        break;

                    case "3":
                        continuar = false;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("Error: " + ex);
                }
            } while (continuar);
        }
コード例 #3
0
        public void CrearSemilla()
        {
            bool   continuar = true;
            string mensaje   = "";

            do
            {
                Console.Clear();

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(mensaje);
                Console.ForegroundColor = ConsoleColor.White;
                try
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("----------- Menu Crear Semilla ----------");
                    Console.WriteLine("1 Crear");
                    Console.WriteLine("2 Regresar");
                    Console.WriteLine("----------- Menu Crear Semilla ----------");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("Seleccione una opcion del menu");
                    string opc = Console.ReadLine();
                    switch (opc)
                    {
                    case "1":
                        Console.WriteLine();
                        Console.Write("Digite el  Tipo: ");
                        string tipo = Console.ReadLine();
                        Console.Write("Digite la Cantidad de agua: ");
                        string CantidadAgua = Console.ReadLine();
                        Console.Write("Digite la Cantidad de sombra: ");
                        string CantidadSombra = Console.ReadLine();
                        Console.Write("Desea Guardar ? S/N : ");
                        string save = Console.ReadLine();
                        if (save.Equals("S"))
                        {
                            Semilla s = new Semilla();
                            s.Tipo           = tipo;
                            s.CantidadAgua   = int.Parse(CantidadAgua);
                            s.CantidadSombra = int.Parse(CantidadSombra);
                            s.Id             = (bodega.getListSemillas().Length) + "";
                            bodega.addSemilla(s);
                            mensaje = "Semilla Creada";
                        }
                        else
                        {
                            mensaje = "Se cancelo la accion";
                        }
                        break;

                    case "2":
                        continuar = false;
                        break;

                    default:
                        Console.Write("Selecciona una opcion valida: ");
                        opc = Console.ReadLine();
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("Error: " + ex);
                    continuar = false;
                }
            } while (continuar);
        }