Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Quantos habitantes há na cidade?");
            var max = int.Parse(Console.ReadLine());

            Habitante H = new Habitante();

            H.idade = new int [max];   H.nome = new string[max];

            for (var i = 0; i < max; i++)
            {
                Console.WriteLine("Qual o nome do " + (i + 1) + "º habitante?");
                H.nome[i] = Console.ReadLine();

                Console.WriteLine("E qual a sua idade?");
                H.idade[i] = int.Parse(Console.ReadLine());
            }
            for (var i = 0; i < max; i++)
            {
                if (H.idade[i] > 20)
                {
                    Console.WriteLine(H.nome[i] + " tem mais de 20 anos e pertence ao grupo A");
                }
                else if (H.idade[i] < 15)
                {
                    Console.WriteLine(H.nome[i] + " tem menos de 15 anos e pertence ao grupo B");
                }
            }
            Console.WriteLine("O restante não faz parte de nenhum grupo.");
        }
Beispiel #2
0
        public void Setup()
        {
            batiriñonera = new List <Tecnologias>();
            Tecnologias batibumerangs = new Tecnologias("Batibumerangs", 100, 1);

            batiriñonera.Add(batibumerangs);
            batman = new Batman(batiriñonera);

            villanos = new List <Villano>();
            Psicopatas psicopata = new Psicopatas(5, 100);

            villanos.Add(psicopata);

            Habitante habitante   = new Habitante(2000000);
            Habitante habitante1  = new Habitante(7000000);
            Habitante habitante2  = new Habitante(8000000);
            Habitante habitante3  = new Habitante(9000000);
            Habitante habitante4  = new Habitante(10000000);
            Habitante habitante5  = new Habitante(11000000);
            Habitante habitante6  = new Habitante(12000000);
            Habitante habitante7  = new Habitante(13000000);
            Habitante habitante8  = new Habitante(14000000);
            Habitante habitante9  = new Habitante(15000000);
            Habitante habitante10 = new Habitante(16000000);
            Habitante habitante11 = new Habitante(500000);

            habitantes = new List <Habitante>();
            habitantes.Add(habitante);
            habitantes.Add(habitante1);
            habitantes.Add(habitante2);
            habitantes.Add(habitante3);
            habitantes.Add(habitante4);
            habitantes.Add(habitante5);
            habitantes.Add(habitante6);
            habitantes.Add(habitante7);
            habitantes.Add(habitante8);
            habitantes.Add(habitante9);
            habitantes.Add(habitante10);
            habitantes.Add(habitante11);
            ciudadGotica = new CiudadGotica(habitantes);
        }