Hands on Testing Java: Lab #11

Homework Projects

Configure Your Project

  1. Create a file named Design/project11.txt.
  2. Create a new package in your project named edu.INSTITUTION.USERNAME.hotj.project11.
  3. Create the classes needed for the assigned project as part of the edu.INSTITUTION.USERNAME.hotj.project11 package.

The Projects

Your instructor will assign you one of the problems below. To solve your problem, write a program that reads the necessary information to compute and output the indicated values, as efficiently as possible. Following the pattern in the lab exercise, first, design using OCD. Then code your design in Java using stepwise translation. Test your program thoroughly.

When executing your program to hand in as part of the project, a JUnit test case should test each method at least five times, but the test case itself needs to be executed just once. A driver program should be run at least five times with different inputs each time.

Project #11.1: Write an implementation for AccountCharge as a subclass of MonthlyModifier. I should subtract a monthly charge, either a flat-rate fee or a percentage of the balance, whichever is smaller. Thouroughly test the class with AccountChargeTest. Then add this montly modifier as appropriate to the tests in AccountTest.

Project #11.2: Write AccountTest#testInterestAccount().

Project #11.3: Write a monthly modifier to enforce the special penalty for a CD account (perhaps called CDAccountPenalty). Write AccountTest#testCDAccount() to do integration testing on all of the modifiers of a CD account.

Project #11.4: Write an integration test for an "auto-pay account" (i.e., AccountTest#testAutoPayAccount()). An auto-pay account is like a checking account except it has a monthly modifier to write checks at the end of a month. For a simple implementation, you could just simply subtract the amount of the check from the balance. For a more interesting implementation, collect the "checks" in a list which could be listed through the auto-pay modifier. (Hint: do not try to get the Account to print the checks!)

Project #11.5: Write an integration test for a "Christmas account" (i.e., AccountTest#testChristmasAccount()). A Christmas account has no fees associated with it. It pays 20% annual interest. The user can make any number of deposits that they wish for up to eleven months. No withdrawals can be made until the twelfth month. After the twelfth month money can only be withdrawn and no interest will be paid. This will require new monthly modifiers which should be tested thoroughly on their own.

Project #11.6: Design and build a class hierarchy for media types stored in a package. Your hierarchy should support Books, Periodicals, VideoTapes and CDs. Some attributes for these kinds of objects include: title, author, ISBN number, subject, running time, volume number, rating, and lending length.

Store the hierarchy in a package and then write a program that creates an array of media types and uses that to demonstrate the correctness of your design and implementation.

Project #11.7: Design and build a class hierarchy for shapes. Your hierarchy should support circles, ovals, triangles, right triangles, squares, rectangles, quadrilaterals. Each class should have appropriate attributes in order to be able to determine: the smallest rectangle that bounds the shape, the area of the shape, the circumference of the shape, whether a point is inside the shape, and whether two shapes bounding rectangles intersect.

Store the hierarchy in a package and then write a program that creates an array of shape types and uses that to demonstrate the correctness of your design and implementation.

Turn In

Turn the following things:

  1. This grade sheet
  2. An OCD design for one of your methods.
  3. All source files you created for your project.
  4. Sample executions of your test cases and drivers (as applicable).

Lab Home Page | Prelab Questions | Lab Exercise | Homework Projects