Figure xx: The design recipe: A complete example


class ProblemSet1 extends JPFalt {
    public static void main(String[] args) {new ProblemSet1();}

    /* Purpose: to compute the area of a ring, whose radius is
                outer and whose hole has radius of inner
     ------------------------------------------------------------*/
    /* Example: areaOfRing(6.0, 1.0) should produce 110.9525
     ------------------------------------------------------------*/
    double areaOfRing(double outer, double inner){
        return areaOfDisk(outer) - areaOfDisk(inner);
    }

    /*-------------------------------------------------------------
     Tests:
     ------------------------------------------------------------*/
    void areaOfRingTests(){

        testHeader ( "areaOfRing" );

        expected(3.1415);
        actual  ( areaOfRing(1.0, 0.0) );   // expected result: 3.1415

        expected(9.4245);
        actual  ( areaOfRing(2.0, 1.0) );   // expected result: 9.4245

        expected(109.9525);
        actual  ( areaOfRing(6.0, 1.0) );   // expected result: 109.9525

    }
}