CS 351 Design of Large Programs

Assignment 1: JUnit Testing

Due Weds Sep 3 7:00pm

Deliver via email: dgodinez (at) cs.unm.edu


Deliverable must include:

Part 1

Create a class called DeathBox that conforms to the following spec.
  1. If you put anything that's not an integer, or a String containing an integer, into the DeathBox, you die.
    Take integer to be a 32 bit java integer, and the string should be parsable using string to int (Integer.valueOf( str ).intValue())
  2. If you put anything outside 6 to 60 into the DeathBox, you die.
  3. If you put anything into the DeathBox that's more than three times the last thing put into the DeathBox, you die.
  4. If you put the same thing into the DeathBox more than three times, you die.
  5. You can't put anything into the DeathBox after you've died.
  6. If the thing you put into the DeathBox doesn't cause you to die according to the rules 1-5, then you live.
Example:
package com.putable.deathbox;
           
/**        
 * The interface presented by a DeathBox, into which only some
 * objects may be safely put, otherwise you die.
 *         
 * @author ackley
 *         
 */        
public interface DeathBox {
  /**
   * Attempt to put another object into a DeathBox.
   * 
   * @param o the object to attempt to place in the DeathBox
   * @return true if o was put into the DeathBox successfully, and
   *         false if 'you died' attempting to put it in (or were
         *         already dead before the latest putInto attempt).
   */
  public boolean putInto(Object o) ;
}          
         

Part 2

  1. Create a JUnit test suite for your DeathBox Class.
  2. Create individual test functions for each item in the spec
We will be looking for clean, readable code in both the DeathBox class and test suite.