The solution is incorrect and not a test.
Your method takes two integers as input and returns an integer. You need to create a Rational class with the nominator and denominator fields. Use it as an argument type and return type.
, 10/21, , . junit , , . , , , .
Rational.
. , , , .
, rational.reciprocal(), toString , , System.out.println(rational.reciprocal());
public class Rational {
private final int num;
private final int den;
public Rational(int numIn, int denIn) {
num = numIn;
den = denIn;
}
public int getNum() {
return num;
}
public int getDen() {
return den;
}
public String toString() {
return num + "/" + den;
}
public Rational reciprocal() {
return new Rational(den,num);
}
public static Rational multiply(Rational a, Rational b) {
return new Rational(a.num * b.num , a.den * b.den );
}
public Rational divide(int a) {
return new Rational(this.num,a*this.den);
}
}