예제 #1
0
    public static void Main(string[] args)
    {
        Aluno a = new Aluno("Pedro", DateTime.Parse("1992-01-01"));
        Aluno b = new Aluno("Arlindo", DateTime.Parse("1993-01-01"));
        Aluno c = new Aluno("Lis", DateTime.Parse("1991-02-01"));

        Aluno[]       v = { a, b, c };
        AlunoNascComp x = new AlunoNascComp();

        Array.Sort(v, x);
        foreach (Aluno i in v)
        {
            Console.WriteLine(i);
        }

        Relatorio.Aniversariantes(v, 1);

        Professor p1 = new Professor {
            Nome = "Patricia", Nascimento = DateTime.Parse("1980-01-01")
        };
        Professor p2 = new Professor {
            Nome = "Fernando", Nascimento = DateTime.Parse("1980-02-02")
        };

        Professor[] w = { p1, p2 };

        Relatorio.Aniversariantes(w, 1);

        IPessoa[] vw = { a, b, c, p1, p2 };
        Relatorio.Aniversariantes(vw, 1);

        Turma t = new Turma();

        t.SetProfessor(p1);
        t.InserirAluno(a);
        t.InserirAluno(b);
        t.InserirAluno(c);

        Console.WriteLine("Dados da turma");
        Console.WriteLine(t);
        foreach (Aluno y in t.ListarAlunos())
        {
            Console.WriteLine(y.Nome);
        }
        foreach (Aluno y in t.ListarAlunos())
        {
            Console.WriteLine(y);
        }

        Console.WriteLine("Aniversariantes da turma");
        var z =
            from Aluno y in t where y.Nascimento.Month == 1 select y;

        foreach (Aluno y in z)
        {
            Console.WriteLine(y);
        }
    }
예제 #2
0
    public static void Main(string[] args)
    {
        /*
         * var x1 = 10;
         * var x2 = "Teste";
         * var x3 = new Aluno("Pedro", DateTime.Parse("1992-01-01"));
         *
         * Console.WriteLine(x1.GetType());
         * Console.WriteLine(x2.GetType());
         * Console.WriteLine(x3.GetType());
         *
         * dynamic x4 = 10;
         * Console.WriteLine(x4.GetType());
         * x4 = "Teste";
         * Console.WriteLine(x4.GetType());
         */
        Aluno a = new Aluno("Pedro", DateTime.Parse("1992-01-01"));
        Aluno b = new Aluno("Maria", DateTime.Parse("1993-01-01"));
        Aluno c = new Aluno("Paulo", DateTime.Parse("1991-02-01"));

        Aluno[] v = { a, b, c };
        //Array.Sort(v);
        AlunoNascComp x = new AlunoNascComp();

        Array.Sort(v, x);
        foreach (Aluno i in v)
        {
            Console.WriteLine(i);
        }

        Console.WriteLine("Alunos aniversariantes");
        Relatorio.Aniversariantes(v, 1);

        Professor p1 = new Professor {
            Nome       = "Patricia",
            Nascimento = DateTime.Parse("1980-01-01")
        };
        Professor p2 = new Professor {
            Nome       = "Fernando",
            Nascimento = DateTime.Parse("1980-02-02")
        };

        Professor[] w = { p1, p2 };
        Console.WriteLine("Professores aniversariantes");
        Relatorio.Aniversariantes(w, 1);


        IPessoa[] vw = { a, b, c, p1, p2 };
        Console.WriteLine("Todos aniversariantes");
        Relatorio.Aniversariantes(vw, 1);

        Turma t = new Turma();

        t.SetProfessor(p1);
        t.InserirAluno(a);
        t.InserirAluno(b);
        t.InserirAluno(c);
        Console.WriteLine("Dados da turma");
        Console.WriteLine(t);
        foreach (Aluno y in t.ListarAlunos())
        {
            Console.WriteLine(y.Nome);
        }
        foreach (Aluno y in t)
        {
            Console.WriteLine(y);
        }
        Console.WriteLine("Aniversariantes da turma");

        /*var z =
         * from Aluno y in t where y.Nascimento.Month == 1 select new {y.Nome}; */
        var z =
            from Aluno y in t where y.Nascimento.Month == 1 select y;

        Console.WriteLine(z.GetType());
        foreach (Aluno y in z)
        {
            Console.WriteLine(y);
        }
        //foreach(var y in z) Console.WriteLine(y);
    }