Exemplo n.º 1
0
        public Book(int isbn, string author, string name, int edition, int editionYear, int pages, double price)
        {
            BookValidation.CheckInput(isbn, author, name, edition, editionYear, pages, price);

            Isbn        = isbn;
            Author      = author;
            Name        = name;
            Edition     = edition;
            EditionYear = editionYear;
            Pages       = pages;
            Price       = price;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes book from the collection
        /// </summary>
        public void RemoveBook(int isbn, string author, string name, int edition, int editionYear, int pages, double price)
        {
            BookValidation.CheckInput(isbn, author, name, edition, editionYear, pages, price);

            int position = BookExists(isbn, author, name, edition, editionYear, pages, price);

            if (position != -1)
            {
                AllBooks.RemoveAt(position);
            }
            else
            {
                throw new ArgumentException("The book wasn't found.");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds new book to the collection
        /// </summary>
        public void AddBook(int isbn, string author, string name, int edition, int editionYear, int pages, double price)
        {
            BookValidation.CheckInput(isbn, author, name, edition, editionYear, pages, price);

            int position = BookExists(isbn, author, name, edition, editionYear, pages, price);

            if (position == -1)
            {
                AllBooks.Add(new Book(isbn, author, name, edition, editionYear, pages, price));
            }
            else
            {
                throw new ArgumentException("Such book already exists.");
            }
        }