Answer 12: Writing the Test First

The design of the Fraction class requires the object to be immutable

    public void testSquare() {
        Fraction a = Fraction.getFraction(1, 2);
        Fraction b = a.square();
        assertEquals(b, Fraction.ONE_QUARTER);
    }

Previous | Next | Top | Cafe con Leche | Cafe au Lait

Copyright 2005 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified November 11, 2005