私のコードはほぼ完成していますが、「reduceToLowestTerms()」が私のコードで実装されない理由を理解し、Fraction を入力するたびにそれが実行されることを確認する必要があります。
私のコードは少し長いので、リンクを投稿します! https://gist.github.com/anonymous/0421493909708268ea9e
private void reduceToLowestTerms()
{
this.switchSign();
int i1 = greatestCommonDivisor(this.numerator, this.denominator);
this.numerator = this.numerator / i1;
this.denominator = this.denominator / i1;
} // end reduceToLowestTerms
private int greatestCommonDivisor(int integerOne, int integerTwo)
{
int result;
if (integerOne % integerTwo == 0)
result = integerTwo;
else
result = greatestCommonDivisor(integerTwo, integerOne % integerTwo);
return result;
}
これは、何らかの理由でコードの残りの部分に実装されていないコード セクションです。