Exemplo n.º 1
0
        //Removing a Book from the Book List
        public Book removeBook(Book removeBook)
        {
            BookStorage books = new BookStorage();

            string[,] listBooks = books.allBooks();
            removeBook.check    = false;
            int index = 0;

            while (removeBook.check == false && index < 100)
            {
                if (removeBook.isbn == listBooks[index, 0])
                {
                    removeBook.check = true;
                }
                else
                {
                    index += 1;
                }
            }
            for (int i = index; i < 99; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    listBooks[i, j] = listBooks[i + 1, j];
                }
            }
            books.writeAllBooks(listBooks);
            return(removeBook);
        }
Exemplo n.º 2
0
        public Book editBook(Book editBook)
        {
            BookStorage books = new BookStorage();

            string[,] listBooks = books.allBooks();
            editBook.check      = false;
            int counter = 0;

            while (editBook.check == false && counter < 100)
            {
                if (editBook.isbn == listBooks[counter, 0])
                {
                    listBooks[counter, 1] = editBook.title;
                    listBooks[counter, 2] = editBook.author;
                    listBooks[counter, 3] = editBook.description;
                    listBooks[counter, 4] = editBook.stockNum;
                    editBook.check        = true;
                }
                counter += 1;
            }
            if (editBook.check == true)
            {
                books.writeAllBooks(listBooks);
            }
            else if (editBook.check == false)
            {
                editBook.isbn = "BOOK IS NOT IN SYSTEM";
            }
            return(editBook);
        }