// El constructor de Fraction establece el invariante; plus y times lo conservan.
public class FractionDemo {
    public static void main(String[] args) {
        Fraction half = new Fraction(2, 4);
        Fraction third = new Fraction(1, -3);
        IO.println("2/4  -> " + show(half));
        IO.println("1/-3 -> " + show(third));
        IO.println("suma:     " + show(half.plus(third)));
        IO.println("producto: " + show(half.times(third)));
        IO.println("half sigue siendo " + show(half));
        new Fraction(1, 0);         // termina con una excepción
    }

    static String show(Fraction f) {
        return f.numerator() + "/" + f.denominator();
    }
}
