저는이 작업을 올바르게 수행하고 있다고 생각하지만 올바르게 분수 클래스에서 ImproperFraction 메서드에 문제가 있습니다. 단순히 출력이 쇠퇴하거나 분수가 부적절하지 않고 특별한 것이 필요하지 않습니다. 메인 클래스에서Java에서 부적절한 분수 출력 문제가 있습니다.
public boolean ImproperFraction(Fraction otherObject1){
if(numerator > denominator) {
System.out.println("Your fraction is improper and cannot be reduced");
Fraction otherFraction = (Fraction)otherObject1;
return ((numerator == otherFraction.numerator) &&
(denominator == otherFraction.denominator));
}
else if(numerator <= denominator) {
System.out.println("Your fraction is proper and has been reduced");
return false;
}
else {
return false;
}
}
:
System.out.println(ImproperFraction);
그것은 내가 그것을 넣어 비율이 부적절한 경우에도 false를 반환하고있는 것을 유일한 것은. 어떤 도움을 주셔서 감사합니다!
분자와 분모는 어디에서 오는가? – panoptical
왜 프란 션 번호를 다른 분수 번호와 비교하여 부적절한 분수인지 여부를 결정합니까? 테스트중인 분수의 분자와 분모를 비교해야합니다. – anonymous
'Fraction' 클래스에있는 메소드입니까? 그렇다면 첫 번째 것이 부적절한 것인지 테스트하기 위해 두 번째 부분을 전달할 필요가 없습니다. 어쩌면 당신은'otherObject1'을 없애고'if' 블록 안에 메시지를 출력 한 후에'true'를 리턴해야합니다. –