Name (print) ___________________________________   Lab Section you attend______________

CSE131 Module 5 Extension
Test-Driven Development
Take-home, due with Module 5 or at an extension deadline

As with the practice problems, write the simplest code or test for a Composite class that causes the test to pass. The Fraction type is defined as in lecture.
Test Code Implementation
public void test0() {
   Composite c = new Composite();
   assertEquals(0, c.getInteger());
   assertEquals(0, c.getFraction().toDouble());
public void test1() {

public class Composite {
   private Fraction fraction;
   public Composite(int integer, Fraction f) {
      this.fraction = f;
   public Fraction getFraction() { return fraction; }
public void test2() {
   Fraction f = new Fraction(3,2);
   Composite c = new Composite(f);
   assertEquals(1, c.getInteger());
   asssertEquals(0.5, c.getFraction().toDouble());
   Composite d = new Composite(new Fraction(9,4));
   assertEquals(2, d.getInteger());
   assertEquals(0.25, d.getFraction().toDouble());