package application;

public class Rational {
     private int x;
     private int y;
     
     public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Rational add(Rational r1, Rational r2) {
    	 Rational temp = new Rational();
    	 temp.x = r1.x * r2.y + r1.y * r2.x; 
    	 temp.y = r1.y * r2.y; 
    	 return temp; 
     }
	public Rational multiply(Rational r1, Rational r2) {
   	  Rational temp = new Rational();
   	  temp.x = r1.x * r2.x; 
   	  temp.y = r1.y * r2.y; 
   	  return temp; 
    }
	public Rational subtract(Rational r1, Rational r2) {
   	 Rational temp = new Rational();
   	 temp.x = r1.x * r2.y - r1.y * r2.x; 
   	 temp.y = r1.y * r2.y; 
   	 return temp; 
    }
	public Rational division(Rational r1, Rational r2) {
	   	  Rational temp = new Rational();
	   	  temp.x = r1.x * r2.y; 
	   	  temp.y = r1.y * r2.x; 
	   	  return temp; 
	}
}
