Exemplo n.º 1
0
/*
 *      public int Isbn {   get { return this.isbn; }   set { this.isbn = value; } }
 *      public string Titulo {  get { return this.titulo; }     set { this.titulo = value; } }
 *      public String Autor {get { return this.autor; }set { this.autor = value; }}
 *      public String Editora{get { return this.editora; }set { this.editora = value; } }
 *      public List<Exemplar> Exemplares {get { return this.exemplares; }}
 */
        public void adicionarExemplar(Exemplar p)
        {
            //foreach (Exemplar exemp in this.exemplares)
            //    if (exemp.Equals(exemplar)) throw new Exception("Já existe um exemplar com este tombo.");
            //this.exemplares.Add(exemplar);

            // Exemplares é uma lista de Exemplar
            this.exemplares.Add(p);
        }
Exemplo n.º 2
0
        static void registrarDevolucao()
        {
            Console.Write("\nDigite o ISBN: ");
            int isbnE = Int32.Parse(Console.ReadLine());

            Livro livroE = lvs.pesquisar(new Livro(isbnE));

            if (livroE == null)
            {
                throw new Exception("Livro não encontrado.");
            }

            Exemplar exemplarE = livroE.Exemplares.FirstOrDefault(i => i.devolver());

            if (exemplarE != null)
            {
                Console.WriteLine("Exemplar " + exemplarE.Tombo + " devolvido com sucesso!");
            }
            else
            {
                Console.WriteLine("Não há exemplares emprestados.");
            }
        }
Exemplo n.º 3
0
        static void registrarEmprestimo()
        {
            Console.Write("\nDigite o ISBN: ");
            int isbnD = Int32.Parse(Console.ReadLine());

            Livro livroD = lvs.pesquisar(new Livro(isbnD));

            if (livroD == null)
            {
                throw new Exception("Livro não encontrado.");
            }

            Exemplar exemplar = livroD.Exemplares.FirstOrDefault(i => i.emprestar());

            if (exemplar != null)
            {
                Console.WriteLine("Exemplar " + exemplar.Tombo + " emprestado com sucesso!");
            }
            else
            {
                throw new Exception("Não há exemplares disponíveis.");
            }
        }