コード例 #1
0
        static void ExcluirPessoa()
        {
            Negocio         negocio = new Negocio();
            IEmprestimoDado emprestimo;
            IPessoaDado     pessoa;
            int             cpf;

            do
            {
                pessoa = new PessoaDado();

                Console.Write("Informe o CPF: ");
                cpf = Convert.ToInt32(Console.ReadLine());

                pessoa = negocio.BuscarPessoa(pessoa, cpf, pessoas);

                if (pessoa == null)
                {
                    Console.WriteLine("Pessoa invalida, tente novamente!!");
                }
            } while (pessoa == null);
            emprestimo = new EmprestimoDado();

            emprestimo = negocio.BuscarPessoaEmprestimo(emprestimo, pessoa, emprestimos);
            if (emprestimo == null)
            {
                pessoas.Remove(pessoa);
                Console.WriteLine("Pessoa excluida com sucesso!!");
            }
            else
            {
                Console.WriteLine("Pessoa possui um emprestimo!!");
            }
        }
コード例 #2
0
        static void ExcluirLivro()
        {
            Negocio         negocio = new Negocio();
            IEmprestimoDado emprestimo;
            ILivroDado      livro;

            do
            {
                livro = new LivroDado();
                Console.Write("Digite o tombo para Excluir: ");
                int tombo = Convert.ToInt32(Console.ReadLine());

                livro = negocio.BuscarLivro(livro, tombo, livros);

                if (livro == null)
                {
                    Console.WriteLine("Livro invalido, tente novamente!!");
                }
            } while (livro == null);
            emprestimo = new EmprestimoDado();

            emprestimo = negocio.BuscarLivroEmprestimo(emprestimo, livro, emprestimos);

            if (emprestimo == null)
            {
                livros.Remove(livro);
                Console.WriteLine("Livro removido com sucesso!!");
            }
            else
            {
                Console.WriteLine("Livro sendo usado!!");
            }
        }
コード例 #3
0
        static void DevolverLivro()
        {
            Negocio         negocio = new Negocio();
            IEmprestimoDado emprestimo;

            do
            {
                emprestimo = new EmprestimoDado();
                Console.Write("Informe o ID do emprestimo: ");
                int id = Convert.ToInt32(Console.ReadLine());

                emprestimo = negocio.BuscarEmprestimo(emprestimo, id, emprestimos);
                if (emprestimo == null)
                {
                    Console.WriteLine("Emprestimo nao existe, tente novamente!!");
                }
            } while (emprestimo == null);
            emprestimos.Remove(emprestimo);
            Console.WriteLine("Devolução realizada com sucesso!!");;
        }
コード例 #4
0
        static void AlugarLivro()
        {
            Negocio         biblioteca = new Negocio();
            IEmprestimoDado emprestimo = new EmprestimoDado();
            IPessoaDado     pessoaDado;
            ILivroDado      livroDado;

            do
            {
                pessoaDado = new PessoaDado();
                livroDado  = new LivroDado();

                Console.Write("Informe o cpf: ");
                int cpf = Convert.ToInt32(Console.ReadLine());
                Console.Write("Informe o tombo do livro: ");
                int tombo = Convert.ToInt32(Console.ReadLine());

                pessoaDado = biblioteca.BuscarPessoa(pessoaDado, cpf, pessoas);
                livroDado  = biblioteca.BuscarLivro(livroDado, tombo, livros);
            } while (pessoaDado == null || livroDado == null);
            emprestimos.Add(biblioteca.Emprestar(livroDado, pessoaDado, emprestimo, emprestimos));

            Console.WriteLine("Emprestimo realizado!!");
        }