Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement this assignment using JAVA Note: Implementation should be using JAVA Language. Object-Oriented Programming Lab#5, Fall 2020 Today's Topics Class/Object, Constructor, package Array (Reference Type)

Implement this assignment using JAVA

image text in transcribed

image text in transcribed

Note: Implementation should be using JAVA Language.

Object-Oriented Programming Lab#5, Fall 2020 Today's Topics Class/Object, Constructor, package Array (Reference Type) ArrayList ArrayList: Action Creating an ArrayList Adding element to arraylist Accessing an element Size of arraylist Code ArrayList list = new ArrayList(); list.add(T); List.get(int index) list.size(); Problems/Assignments - Book Store Application Create a book store application which will help a book store owner to keep the record of its books and run the business. The Book store application will help the store to keep the list of available books and have the functionalities to 1) display all available books, 2) sell books (should be able to sell multiple copies), and 3) order new/existing books from publishers. Each book in the system will have 3 attributes; bookTitle, bookAuthor, and numberOfCopies. With sell or order of existing books, number of copies attribute will decrease/increase. With order of new book, a new book entry will be added to the system. The system will display a menu on the screen for the user to choose from. Here is the menu. Enter "1", to display the Books: Title - Author - Quantity. Enter "2", to order new books. Enter "3", to sell books. Enter "O", to exit the system. Here is what you need to do to implement the Book Store. 1) Create the following Book class. Book String book Title String bookAuthor int numOfCopies Book(String, String, int) void display() a. display() method will display the book info in "Title - Author - Quantity" format. Or create toString(). 2) Create another class "BookStore" which should contain all the book objects. For now you can use an array of Book type and assume you can have maximum 10 different books (each book will have multiple copies). Or if you use ArrayList, no capacity restriction is needed. BookStore String name Book[] books void sell(String bookTitle, String author, int noOfCopies) void order(String bookTitle, String author, int noOfCopies) void display() a. sell(String, String, int) method will search for the book in "books" array using the bookTitle and bookAuthor. If the book is found in the list, number of copies will decrease. If the book is not found, a message should display. b. order(String, String, int) method will order book for the book store. You have to handle both new book and existing book scenario. i. First search for the book in "books array using the bookTitle and bookAuthor value. ii. If the book is found in the list (which means the book already exists in the system), number of copies will increase. iii. If the book is not found (which means the book does not exists in the system and you need to order new book), a new book entry will be added to the "books" array/arraylist. display() method will display info of all books in "books" array "Title - Author - Quantity" format. Use Book class's display() method to display each book's info. 3) Now create class "BookStore App" which should contain the main method. In main method create an object of BookStore class and then provide the menu as mentioned before. Once the user enters his/her option, you need to read the value and take appropriate action (See below) using the BookStore object. . . For option 1, display all the books in the format above, with each one on a separate line. For option 2, the system will allow you to order one or more books. For this option, you need to take bookTitle and bookAuthor and no. of copies as input from user. For option 3, the system will allow you to sell one or more books. It will ask user to enter the book Title and bookAuthor and no. of copies to sell book. For option 0, exit the application by breaking the loop or system exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions