コード例 #1
0
ファイル: Book.cs プロジェクト: Lamiaroid/.NET_Epam
        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;
        }
コード例 #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
            {
                bookLogger.Error($"The book wasn't found. ISBN: {isbn}; Author: {author}; Name: {name}; Edition: {edition}; Edition year: {editionYear}; Number of pages: {pages}; Price: {price};");
                throw new ArgumentException("The book wasn't found.");
            }
        }
コード例 #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
            {
                bookLogger.Error($"Such book already exists. ISBN: {isbn}; Author: {author}; Name: {name}; Edition: {edition}; Edition year: {editionYear}; Number of pages: {pages}; Price: {price};");
                throw new ArgumentException("Such book already exists.");
            }
        }