Beispiel #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);

            this.Isbn        = isbn;
            this.Author      = author;
            this.Name        = name;
            this.Edition     = edition;
            this.EditionYear = editionYear;
            this.Pages       = pages;
            this.Price       = price;
        }
Beispiel #2
0
        /// <summary>
        /// Removes book from the collection
        /// </summary>
        /// <param name="isbn">Isbn</param>
        /// <param name="author">Author</param>
        /// <param name="name">Name</param>
        /// <param name="edition">Edition</param>
        /// <param name="editionYear">Edition year</param>
        /// <param name="pages">Number of pages</param>
        /// <param name="price">Price</param>
        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 = this.BookExists(isbn, author, name, edition, editionYear, pages, price);

            if (position != -1)
            {
                this.AllBooks.RemoveAt(position);
            }
            else
            {
                throw new ArgumentException("The book wasn't found.");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Adds new book to the collection
        /// </summary>
        /// <param name="isbn">Isbn</param>
        /// <param name="author">Author</param>
        /// <param name="name">Name</param>
        /// <param name="edition">Edition</param>
        /// <param name="editionYear">Edition year</param>
        /// <param name="pages">Number of pages</param>
        /// <param name="price">Price</param>
        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 = this.BookExists(isbn, author, name, edition, editionYear, pages, price);

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