/**** * Class SimpleFractionTest is a very small example illustrating what your * FractionTest class can look like for Programming Assignment 1. */ public class SimpleFractionTest { /** * Call the test method for testNumeratorDenominator. In the complete * FractionTest you're writing, this main method calls all of the faction * test methods. */ public static void main(String[] args) { testNumeratorDenominatorConstructor(); } /** * Test the full initializing constructor of the Fraction class with three * sample test cases. In the full version of this test method you'll need * some additional test cases. Use the guidelines in Lecture Notes 2 to * help figure out what the additional test case should be. */ private static void testNumeratorDenominatorConstructor() { Fraction f; // value produced by the constructor int n; // convenience varible for the numerator value int d = 0; // convenience varible for the denominator value // Test Case 1: check the boundary case of a zero numerator "0/1". f = new Fraction(0,1); if ((n = f.getNumerator()) != 0 || (d = f.getDenominator()) != 1) { System.out.println("Got " + n + "/" + d + ", expected 0/1"); } // Test Case 2: check a simple case the doesn't need reduction. f = new Fraction(1,2); if ((n = f.getNumerator()) != 1 || (d = f.getDenominator()) != 2) { System.out.println("Got " + n + "/" + d + ", expected 1/2"); } // Test Case 3: check a case that needs some reduction. f = new Fraction(4,8); if ((n = f.getNumerator()) != 1 || (d = f.getDenominator()) != 2) { System.out.println("Got " + n + "/" + d + ", expected 1/2"); } } }