Question

The consulting company’s design for the project is in the form of Java interfaces. You will need to write classes to implement these interfaces, as well as tests for the classes. The first phase of the project will provide the infrastructure to allow Books & More to track their inventory. Later phases, as planned by the consulting company, will add additional functionality.

The interfaces you must implement include: Product, Lookup, and Company.

For Product, you must implement classes that represent the different types of products Books & More sells: Book, Magazine, and GiftCard. The consulting company created the skeleton of these classes, you need to complete the classes and their corresponding test classes based on the documentation in these classes. GregorianCalendar class is used to track the publication date for magazines or books. A GregorianCalendar object may be constructed by calling
new GregorianCalendar() ; // for today
new GregorianCalendar(year, month, day); // where month is 0 – 11 (0 indexed)
More detail of its use is found in the Java library documentation.

For Lookup, the consulting company created three different ways to look up products: NameLookup, IdLookup, and LowStockLookup. Again, these might not work correctly or even be completed, so test first and then fix any problems you find.

The Company interface represents information about the store running the inventory system. The BooksAndMore class implements Company and serves to keep track of the inventory for an individual store.

The consulting company also created an interface Money and a class Dollar that implements Money. This is used in Product to track the price of a product. Although the Dollar class has been coded already, you should write tests to be sure it is fully functional.

The consulting company does not have any user interface at this time. You suspect they have another employee working on something for down the road.

The consulting company used the following comment, /*# insert code here */, to indicate methods that still need implementing. While these comments are a clear sign that work needs to be done, do not assume that methods without these comments are correct. Make sure everything is fully tested!

While the management at Books & More wants you to adhere to the interfaces and class names created by the consulting company, you realize that you will need to create data members in the classes to store any needed information.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class Book implements Product
{

private String description, name, ID;
private Money price;
private int quantity;
private GregorianCalendar date;

/**
* Constructor for objects of class Book.
*/
public Book()
{
date = new GregorianCalendar();
price = new Dollar();
/*# insert code here */
}

/**
* Return the description of the book.
* @return the description.
*/
public String getDescription()
{
return description;
}

/**
* Change the description of the book to the given parameter.
* @param desc the new description.
*/
public void setDescription(String desc)
{
description = desc;
}

/**
* Return the price of the book.
* @return the price.
*/
public Money getPrice()
{
return price;
}

/**
* Change the price of the book to the given parameter.
* @param price the new price.
*/
public void setPrice(Money price)
{
this.price = price;
}

/**
* Return the title of the book.
* @return the title.
*/
public String getName()
{
return name;
}

/**
* Change the title of the book to the given parameter.
* @param name the new name.
*/
public void setName(String name)
{
this.name = name;
}

/**
* Return the ISBN of the book.
* @return the ISBN.
*/
public String getId()
{
return ID;
}

/**
* Change the ISBN of the book to the given parameter. Don't worry
* about validating the ISBN for now, we'll work that into a later phase.
* The Books & More people are fine with that.
* @param newId the new ISBN.
*/
public void setId(String newId)
{
this.ID = newId;
}

/**
* Return the quantity of the book remaining in stock.
* @return the quantity.
*/
public int getQuantity()
{
return quantity;
}

/**
* Change the quantity of the book to the given parameter.
* @param quantity the new quantity.
*/
public void setQuantity(int quantity)
{
this.quantity = quantity;
}

/**
* Return the publication date of the book.
* @return the date.
*/
public GregorianCalendar getDate()
{
return date;
}

/**
* Change the date of the book to the given parameter.
* @param date the new date.
*/
public void setDate(GregorianCalendar date)
{
this.date = date;
}

}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Java Program: Strings, Integers, Statements
Homework Solution
$20.00
Java
Programming
Coding
Computer Science
Integers
Statements
Strings
Special Characters
Error Messages
Lines
Input
Output
Variables
Operators
Airplane Seating Chart System Simulation in Java
Homework Solution
$30.00
Java
Programming
Codes
Computer Science
Algorithms
Airplane Seating Chart
Simulation
Tickets
Seats
Diagrams
Coordinates
Customers
Passengers
Methods
Statements
Variables
Array Problems in Java: Summation, Average, Min/Max, Searching, Sorting
Homework Solution
$13.00
Java
Programming
Coding
Computer Science
Arrays
Summation
Average
Minimum Number
Maximum Number
Bubble Sort
Selection Sort
Sequential Search
Binary Search
Algorithms
Input
Output
Methods
Integers
Functions
Arrays in Programming Language Java
Homework Solution
$20.00
Java
Programming
Computer Science
Arrays
Integers
Random Numbers
Methods
Functions
Even Elements
Odd Elements
Prime Numbers
Minimum Values
Maximum Values
Average Values
Loops
Conditions
Statements
The Problem Solver in Java
Homework Solution
$30.00
Java
Programming
Codes
Algorithms
Lists
Tasks
Computer Science
Conversions
Celsius
Fahrenheit
Odd Numbers
Even Numbers
User Choices
Input
Output
Statements
Strings
Mathematical Equations
Variables
Get help from a qualified tutor
Live Chats