Project #4 ~ Bookstore Inventory

A company has presented you with an Application Specification sheet. You, as a consultant, are required to meet the customer’s need in a cost-efficient manner with high quality.

As the programmer, you will need to review the specifications of the application and ensure that you understand the requirements. If the requirements are not clear, it is your responsibility to ask more questions of the customer (in this case, the instructor). After clearly understanding requirements, code the application in Java. Compile, run and test the program application several times. Ensure proper testing by evaluating sample input and output and also by evaluating all possible user entry scenarios.

Because this program may be given to someone else to review, modify or enhance, it is important that you:

  • Define needed variables with “sensible” names
  • Consider establishing constants for values that will not change during the course of the program
  • Use comments to document key “units of work” within the program and to explain any unique programming techniques utilized
  • Ensure readability in the formatting of the program
  • You can use your Client class as an example for the Book class.

Application Title: / Bookstore Inventory
Action Requested: / Create newclass and demonstrate how it works with a driver program
Application Purpose: /
  1. Design and implement a class called Book that contains instance data for the title, author, price and quantity (stock on hand).
  1. Define the Book constructor to accept and initialize(give values to) this data. Create a toString method that returns nicely formatted details of the book (such as author, title, price and quantity). Include a setter/mutator and getter/accessor method for all instance data.
  1. In addition, create a method called changeQuantityin the Book class that will accept an integer parameter. The changeQuantity method will adjust the quantity/stock on hand of a given book by the amount passed as a parameter. For example, if 5 is passed as a parameter, the quantity will increase by 5 and if -50 is passed, quantity will decrease by 50.
Create a driver class called Bookshelf whose main method performs the following sequential tasks:
instantiates 3 Book objects with an initial quantity of 10 books
use changeQuantity()in the Book classand add 10 copies of the first book to stock
use changeQuantity() and reducestock (quantity) of the second book by 5 copies
use changeQuantity() and try to reduce the stock (quantity) of the third book by 25 copies
changes the author of the third book to “Helwig”
changes the price of the first book to $12.99
displays the final details of each of the 3 books
displays the value of all books in stock
Notes: / You are to instantiate 3 books. Use the book titles and authors listed below .
The methods that change a book’s quantity should protect against reducing the quantity to a negative value. In other words, the quantity/stock on hand of any given book can not be set to a value less than zero. If this request is made, an error message should be displayed and the requested change in quantity not made.
The value of all books in stock is the sum of each book’s quantitymultiplied by price.
Examples: / If 3 books are instantiated at the beginning ofBookshelf with the following information:
“Da Vinci Code”, “McBride”, 16.00, 10
“Life of Pi”, “Martel”, 16.00, 10
“The Kite Runner”, “Hosseini”, 12.99, 10
then the running of the rest of Bookshelf will produce output similar to the following:
Unable to reduce stock of “The Kite Runner” by 25 copies.
“Da Vinci Code” by McBride sells for $12.99 -> 20 in stock
“Life of Pi” by Martel sells for $16.00 -> 5 in stock
“The Kite Runner” by Lewis sells for $12.99 -> 10 in stock
Total value of stock on hand: $469.70
Approval Status: / X / Approved / CIO Smith
Rejected
Assigned To: / Student Consultant / Completion Date: / See Sept 17th

1/1