@Test public void optimizeTest() throws Exception { RationalNumber actual = RationalNumber.create(15, 9); actual.optimize(); RationalNumber expected = RationalNumber.create(5, 3); Assert.assertEquals(expected, actual); }
public void optimize() { int gcd = calcGcd(numerator, denominator); this.numerator = this.numerator / gcd; this.denominator = this.denominator / gcd; }
RationalNumber { public void optimize() { int gcd = calcGcd(numerator, denominator); this.numerator = this.numerator / gcd; this.denominator = this.denominator / gcd; } }
RationalNumber { public void optimize() { int gcd = calcGcd(numerator, denominator); this.numerator = this.numerator / gcd; this.denominator = this.denominator / gcd; } RationalNumber(int numerator, int denominator); }
RationalNumber { public void optimize() { int gcd = calcGcd(numerator, denominator); this.numerator = this.numerator / gcd; this.denominator = this.denominator / gcd; } RationalNumber(int numerator, int denominator); static RationalNumber create(int numerator, int denominator); int getNumerator(); int getDenominator(); void optimize(); String toString(); boolean equals(Object obj); int hashCode(); }
RationalNumber { public void optimize() { int gcd = calcGcd(numerator, denominator); this.numerator = this.numerator / gcd; this.denominator = this.denominator / gcd; } RationalNumber(int numerator, int denominator); static RationalNumber create(int numerator, int denominator); int getNumerator(); int getDenominator(); void optimize(); String toString(); boolean equals(Object obj); int hashCode();  }