Write a class called Rational which has instance variables num and den which hold the numerator and denominator values such that the number is always expressed in reduced form. Include the following methods in the class Rational:

(a) A constructor that accepts two integer parameters a and b and creates a Rational object representing the rational number a=b.

(b) A constructor that accepts one integer parameter a and creates a Rational object representing the number a.

(c) A method called setRational which accepts two integer parameters a and b and sets the number to a/b.

(d) A method called setRational which accepts one integer parameter a and sets the number to a.

(e) A method called getNum that returns the numerator in the reduced form expression of the rational number.

(f) A method called getDen that returns the denominator in the reduced form expression of the rational number.

(g) A method called add which accepts two integers as parameters (say, c and d) and updates num (say, holding value a) and den (say, holding value b) such that num/den= a/b + c/d.

final num and den should be in reduced form.

Heres what i have so far..not sure if im even close

public class Rational { int num; int den; public Rational() { num = 0; den = 1; } public Rational(int a, int b) { if (b == 0) { b=1; } num = a; den = b; reduce(); Rational R = new Rational(num,den); } public void setRational(int a, int b) { if (b == 0) { b=1; } num = a; den = b; reduce(); Rational setR = new Rational(num,den); } public void setRational(int a) { a= a; } private void reduce() { if (num != 0) { int g = gcd(num,den); num = num /g; den = den/g; } } public Rational (int a) { num = a; den = 1; } private static int gcd( int m, int n ) { int mx = Math.max( m, n ); int mn = Math.min( m, n ); int remainder = 1; while ( remainder != 0 ) { remainder = mx % mn; mx = mn; mn = remainder; } return mx; } public static void main(String[] args) { } }