Features of Java Bookstore Application
The application has been built using the JAVA language. The console-based application is meant to serve the purpose of maintaining a bookstore. The user can switch into the system as an administrator and add, view, update or delete books from the collection generated.
The program generates an initial array of books and allows the user to add to it. Each book has a unique ISBN, title, author, publishing year and name, price and the numbers in stock. The User can also chose to update the price for the book or the stock count of it. Features of the bookstore application include, adding a new book, searching books by ISBN, Title and Author name, updating stock and price, calculating total stock amount, calculating total stock price, finding out the most expensive book, sorting the collection with respect to author names, deleting a book from the collection and so on.
Start
Client class: Main ( )
- Display menu
- Input choice
- If (wrong choice) display ERROR message and goto step 1, else goto next step
- Call respective functions of the BookStore class, according to user’s choice
BookStore class:
add ( )
- Input book details.
- Create Book type object and add to array.
- Increase array index by 1.
searchBook ( )
- Input ISBN string
- Call function searchISBN from Book class
- If return value is -1 display ISBN missing else return search index.
searchAuthor ( )
- Input author string
- Call function searchAuthor from Book class
- If return value is 0 display Author missing.
searchBook ( )
- Input title string
- Call function searchTitle from Book class
- If return value is -1 display book missing else return search index.
updateStock ( )
- Input ISBN string
- Call function searchBook from Book class
- Input new stock value
- Call updateStock method from Book class for the book object at the returned index in array.
updatePrice ( )
- Input ISBN string
- Call function searchBook from Book class
- Input new stock value
- Call updateStock method from Book class for the book object at the returned index in array.
mostExp ( )
- Check if totalBook is 0
- If yes return back, else next step
- Set variable max to 0
- For each object in array, get price
- Check if price is > max, and update max and index to that price and index respectively.
- Display book details
totalStock ( )
- Check if totalBook is 0
- If yes return back, else next step
- Set totalStock to 0
- For each object in array, get stock value and add to totalStock
- Return totalStock
netPrice ( )
- Check if totalBook is 0
- If yes return back, else next step
- Set price to 0
- For each object in array, get stock value and add to price
- Return price
displayAll ( )
- Check if totalBook is 0
- If yes return back, else next step
- For each object in array, call the display method from Book class
remove ( )
- Call searchBook method
- If index is returned successfully, goto next step.
- For i = index and less than totalBooks-1, set Collection array value with its next value, and increment i
- Decrease totalBooks value by 1
sort ( )
- Check if totalBook is 0
- If yes return back, else next step
- Sort using reverse bubble sort
- Call displayAll method
End
run:
Name: Seah Leng Ho
Student Number: 33058916
Mode of Enrolment: External, Part time
Welcome to My Book Store
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 1
Enter details for book #1…
Enter the title of the book:
War and Peace
Enter the author name:
Leo Tolstoy
Enter the publisher name:
ABC
Enter the publishing year:
1928
Enter the ISBN:
123456
Enter the price:
$5.5
Enter the number of books in stock:
20
New book added!
Enter details for book #2…
Enter the title of the book:
Wizard of Oz
Enter the author name:
Frank Baum
Enter the publisher name:
XYZ
Enter the publishing year:
Classes and Methods
2009
Enter the ISBN:
987665
Enter the price:
$-9
Price cannot 0 or less! Enter again…Enter the price:
$9
Enter the number of books in stock:
0
Initial stock cannot 0 or less! Enter again…Enter the number of books in stock:
10
New book added!
Enter details for book #3…
Enter the title of the book:
Jungle Book
Enter the author name:
Rudyard Kipling
Enter the publisher name:
QWE
Enter the publishing year:
2010
Enter the ISBN:
159357
Enter the price:
$15.5
Enter the number of books in stock:
12
New book added!
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 2
Enter the title of the book:
The Book of Art
Enter the author name:
Thomas Henry
Enter the publisher name:
Pop Art Publishers
Enter the publishing year:
2017
Enter the ISBN:
102938
Enter the price:
$0
Price cannot 0 or less! Enter again…Enter the price:
$12.5
Enter the number of books in stock:
5
New book added!
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 3
Enter an ISBN to search for:
12345
Book by this ISBN does not exist in collection!!
Main Menu
=========
Enter 1: Create the book collection.
Creating the Book Collection
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 1
Collection has already been initiated!!
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 123456
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 1
Collection has already been initiated!!
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Adding a New Book
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 3
Enter an ISBN to search for:
159357
Book Title: Jungle Book
Book Author: Rudyard Kipling
Book Publisher: QWE
Book Publishing year: 2010
Book ISBN: 159357
Books in Stock: 12
Book Price: $15.5
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 4
Enter the author’s name to search for:
Leo Tolstoy
Book Title: War and Peace
Book Author: Leo Tolstoy
Book Publisher: ABC
Book Publishing year: 1928
Book ISBN: 123456
Books in Stock: 20
Book Price: $5.5
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 5
Enter an ISBN to search for:
123456
Book Title: War and Peace
Book Author: Leo Tolstoy
Book Publisher: ABC
Book Publishing year: 1928
Book ISBN: 123456
Books in Stock: 20
Book Price: $5.5
Enter the new stock quantity for the book:
25
Stock updated!
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Searching Book using ISBN
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 3
Enter an ISBN to search for:
123456
Book Title: War and Peace
Book Author: Leo Tolstoy
Book Publisher: ABC
Book Publishing year: 1928
Book ISBN: 123456
Books in Stock: 25
Book Price: $5.5
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 6
Enter the book title to search for:
Wizard of Oz
Book Title: Wizard of Oz
Book Author: Frank Baum
Book Publisher: XYZ
Book Publishing year: 2009
Book ISBN: 987665
Books in Stock: 10
Book Price: $9.0
Enter the new price for the book:
$
10.6
Price updated!
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 4
Enter the author’s name to search for:
Searching Books by Author Name
Frank Baum
Book Title: Wizard of Oz
Book Author: Frank Baum
Book Publisher: XYZ
Book Publishing year: 2009
Book ISBN: 987665
Books in Stock: 10
Book Price: $10.6
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 7
The most expensive book is:
Book Title: Jungle Book
Book Author: Rudyard Kipling
Book Publisher: QWE
Book Publishing year: 2010
Book ISBN: 159357
Books in Stock: 12
Book Price: $15.5
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 8
Total stock of books in collection is: 52
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 9
Updating Stock by Searching via ISBN
The net cost of all books in collection is: 492.0
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 10
All books in the collection are as follows:
Book Title: War and Peace
Book Author: Leo Tolstoy
Book Publisher: ABC
Book Publishing year: 1928
Book ISBN: 123456
Books in Stock: 25
Book Price: $5.5
Book Title: Wizard of Oz
Book Author: Frank Baum
Book Publisher: XYZ
Book Publishing year: 2009
Book ISBN: 987665
Books in Stock: 10
Book Price: $10.6
Book Title: Jungle Book
Book Author: Rudyard Kipling
Book Publisher: QWE
Book Publishing year: 2010
Book ISBN: 159357
Books in Stock: 12
Book Price: $15.5
Book Title: The Book of Art
Book Author: Thomas Henry
Book Publisher: Pop Art Publishers
Book Publishing year: 2017
Book ISBN: 102938
Books in Stock: 5
Book Price: $12.5
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 11
Enter an ISBN to search for:
159357
Book Title: Jungle Book
Book Author: Rudyard Kipling
Book Publisher: QWE
Book Publishing year: 2010
Book ISBN: 159357
Books in Stock: 12
Book Price: $15.5
Book removed!
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Updating Book Price by Searching via Title
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 12
The sorted collection is as follows…
All books in the collection are as follows:
Book Title: Wizard of Oz
Book Author: Frank Baum
Book Publisher: XYZ
Book Publishing year: 2009
Book ISBN: 987665
Books in Stock: 10
Book Price: $10.6
Book Title: War and Peace
Book Author: Leo Tolstoy
Book Publisher: ABC
Book Publishing year: 1928
Book ISBN: 123456
Books in Stock: 25
Book Price: $5.5
Book Title: The Book of Art
Book Author: Thomas Henry
Book Publisher: Pop Art Publishers
Book Publishing year: 2017
Book ISBN: 102938
Books in Stock: 5
Book Price: $12.5
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 15
Wrong entry!! Try again…
Main Menu
=========
Enter 1: Create the book collection.
Enter 2: Add a new book to the collection.
Enter 3: Search book using ISBN.
Enter 4: Search books by author name.
Enter 5: Update stock by searching via ISBN.
Enter 6: Update book price by searching via title.
Enter 7: Find the most expensive book.
Enter 8: Display the total stock of books.
Enter 9: Calculate and Display the total monetary pricing of all books in stock.
Enter 10: Display all books in stock.
Enter 11: Removes a book from the collection.
Enter 12: Sort and display the Book Collection according to author names.
Enter 0: Exit the system.
Enter now… 0
Thank you!!
BUILD SUCCESSFUL (total time: 5 minutes 54 seconds)