COMP511_Lab

profileERT
COMP511_Lab12.doc

Lab 1 COMP 511

Purpose

To assess your ability to apply the knowledge and skills developed in Module 1 and Module 2. Emphasis will be placed on interfaces, the Strategy design pattern, and polymorphism.

Introduction

You have been contracted by ABC Rentals to develop the first phase of their rental inventory management system. The system will keep track of items that are available for rent on a weekly or monthly basis. There are three different types of items that can be rented: furniture, DVD players and television sets. The furniture can be rented on a weekly or monthly basis, but the DVD players and television sets can be rented only by the week.

In the initial phase of the project, the operations that must be supported by the system include adding an item to the rental inventory, removing an item from the rental inventory, renting an item, returning an item to inventory, and searching for items in inventory.

Functional Requirements

Adding an item

A rental item is assigned an id number when it is added to the inventory system. The id number starts at 1 (for the first item added) and is incremented for each subsequent item added to inventory.

Implementation Note: The method to add an item takes the item to be added as a parameter and should return a Boolean value of true if the item was successfully added. Otherwise the method should return false. A maximum of 300 items may be in inventory at any one time.

Removing an item

An item is removed from the inventory if it has been lost, stolen, broken, is outdated, etc.

Implementation Note: The method to remove an item takes the id number of the item to be removed as a parameter and returns a Boolean value of true if the item was found and removed from inventory or false if it was not found and removed. The id number of a removed item is NOT reused when new items are added to inventory.

Renting an item

Given an id number and the number of weeks the item is to be rented, the rental fee for the item is calculated, and the item is marked as “rented.” When calculating the rental fees for furniture, each four-week rental is considered a monthly rental, for which there is a discounted rate. For example, if a customer wants to rent a piece of furniture for 10 weeks, the customer should be charged for two months at the lower, monthly rate plus two weeks at the weekly rate. If a customer wants to rent a television set for 10 weeks, the customer should be charged 10 times the weekly rate because there is no monthly rate for television sets. An item can be successfully rented only if it exists in inventory and has not already been rented. Renting an item does not remove the item from inventory.

Implementation Note: A flag or indicator should be used to indicate whether or not the item has been rented. If the item does not exist or is already rented, the method should return null. Otherwise the method should calculate and return the rental fee for renting the item.

Returning an item to inventory

An item can be returned to inventory only if it exists in inventory and was rented.

Implementation Note: If the item does not exist or has not been rented, the method should return false. Otherwise the method should return true.

Finding items in inventory

Inventory can be searched by id number or by rental status.

Implementation Note: The method must return an array of items that match the search criterion (id number or rental status). The Strategy design pattern must be used to implement the search functionality. The algorithms to determine if a given item matches the desired criterion should be encapsulated in different implementations of the Lookup interface. To implement and test the findItems method in the ABCRentals class, the correct type of Lookup object must be passed to the method. The findItems method must use the algorithm encapsulated in the matches method in the Lookup object to determine which items in inventory match the desired criterion.

Assignment

Your job is to implement the concrete classes that are supplied as part of this project. You must document and test all the classes you implement. A careful study of the functional requirements and documentation will direct your efforts. You also should examine the javadoc supplied in the folder Lab01Student\doc. Ask your professor for clarification of any of the methods that are imprecisely defined. Any method containing the comment // TODO: Your code here should be modified to perform the task documented in the associated interface. You are responsible for creating any needed instance fields. You also must add comments and update all javadoc to accurately document your implementation. You can create additional methods, as needed, to fully implement your classes.

Note that some additional classes and interfaces are provided to you in a jar file. These classes and interfaces should be used without modification. In fact, the source code for these classes is not available to you, so you must rely on the javadoc documentation to determine what methods are available in these classes. In particular, you will want to examine the documentation for the Money interface and the Dollar class. You can find the javadoc for these interfaces and classes in the folder Lab01Student\jardoc\doc.

Note that a user interface is NOT part of this project. If you wish to create a user interface for your own use, you may do so, but DO NOT include the user interface when you submit the project to WebCAT.

Notes

1. You must use the provided BlueJ starter project and develop your solution using the BlueJ IDE.

2. Do NOT change the name, return type, or parameter order/type of any of the class or methods. These are used by Web-CAT to grade your submission, and you will end up losing points if they are changed.

Each class constructor and method should be tested by a unit test method in the test class. Besides serving to verify that your code is accomplishing what you intended, examining the unit test methods will help you understand how the objects should behave (how the class constructors/methods create, access, and mutate the object). That is, first writing the test methods helps guide your class coding efforts. Follow these steps to complete this assignment:

a. Create the first JUnit test method, completing the code. Note that proper testing may include making manual calculations to verify that expected values for a method action are equivalent to actual results.

b. Once you feel the unit test method is a valid and robust test of the method’s expected behavior, review the corresponding class constructor or method and complete the coding.

c. Run the JUnit test for the method. If it does not pass, review and correct the logic for this method.

d. When the test passes, continue in like manner for the next and subsequent methods, iteratively completing tests and developing your class or classes. All class methods must be tested.

3. All classes must compile cleanly.

4. Check your programming style using the “Check Style” tool provided within BlueJ (Tools ( Checkstyle).

5. Document the overall project in the README file as directed.

6. Submit your completed lab to Web-CAT using BlueJ (Tools ( Submit) and review the Web-CAT results for errors. Repeat the above steps as needed to resolve any errors.

Deliver your program via the special source delivery server at http://webcat.franklin.edu/ through the BlueJ IDE.

1

2