AP Problem 1 (1)

.docx

School

Pennsylvania State University *

*We aren’t endorsed by this school

Course

418

Subject

Accounting

Date

Feb 20, 2024

Type

docx

Pages

2

Uploaded by ProfessorMetalCoyote36

Problem Title: Bookstore Inventory Management System You are tasked with creating a simple inventory management system for a bookstore. Each book in the bookstore is represented by a Book class. The Book class has the following attributes: int bookId : A unique identifier for each book. String bookTitle : The title of the book. String author : The author of the book (author’s name). double price : The price of the book. int quantityInStock : The quantity of the book currently in stock. You are required to implement these methods in the BookstoreInventoryManager class: 1. void addBook(Book book) : Adds a new book to the inventory. If the book already exists in the inventory simply increase the quantity by adding the parameter book’s quantity to that of the book that already exists in the inventory. 2. Book findBookById(int bookId) : Finds and returns the book with the given book ID. Returns null if the book is not found. 3. void updateStock(int bookId, int quantity) : Updates the quantity in stock for the book with the given bookId. 4. double calculateTotalValue() : Calculates and returns the total value of all books in the inventory (price * quantity for each book). 5. Book getMostExpensiveBook() : Returns the Book with the highest price in the inventory. If there are multiple books with the same highest price, return the first one encountered. 6. ArrayList<Book> removeOutOfPrintBooks() : Removes all books from the inventory that are out of print and returns the list of removed books. A book is considered out of print if its quantity in stock is 0. 7. void sortBooksAscending(): Sorts books in the inventory in ascending price order. 8. ArrayList<Book> sortBooksByAuthor(): Returns a sorted list of all books in the inventory in alphabetical order by author. 9. void removeBooksInList(ArrayList<Book> list) : Removes all books in the list from the inventory. Assume the list only contains books that are in the inventory. 10. ArrayList<Book> getBooksByAuthor(String author) : This method returns an ArrayList of all books in the inventory that are written by the specified author. 11. ArrayList<Book> getBooksInPriceRange(double minPrice, double maxPrice) : This method returns an ArrayList of all books in the inventory that have a price within the specified range. 12. ArrayList<Book> getBooksInPriceRangeByAuthor(double minPrice, double maxPrice, String author) : This method returns an ArrayList of all books in the inventory that have a price within the specified range and written by the author. The list should be sorted in ascending price order. Your task is to implement the Book and BookstoreInventoryManager classes and methods according to the specifications above. Provide the class definitions and method implementations for the Book class and the BookstoreInventoryManager class.
Note: You are encouraged to use appropriate data structures, such as an ArrayList, to store and manage the books in the inventory.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help