import javax.swing.*;

public class polar
{
protected double R,teta;
//kurucu metodlar
public polar()
{R=0;teta=0;}

public polar(double Ri,double tetai)
{R=Ri;teta=tetai;}

public polar(polar A)
{R=A.R;teta=A.teta;}

public void read_polar(double Ri,double tetai)
{R=Ri;teta=tetai;}

public double xi()
{
return R*Math.cos(teta);
}

public double xj()
{
return R*Math.sin(teta);
}

public static double Ri(double xi,double yi)
{return Math.sqrt(xi*xi+yi*yi);}

public static double tetai(double xi,double yi)
{return Math.atan2(yi,xi);}

public void read_cartesian(double xi,double xj)
{
R=Math.sqrt(xi*xi+xj*xj);
teta=Math.atan2(xj,xi);
}

public static polar add(polar A,polar B)
{
   double x=A.xi()+B.xi();
   double y=A.xj()+B.xj();
   polar C=new polar(Ri(x,y),tetai(x,y));
   return C;
}

public void add(polar A)
{
   double x=xi()+A.xi();
   double y=xj()+A.xj();
   read_cartesian(x,y);
}

public static polar substract(polar A,polar B)
{
   double x=A.xi()-B.xi();
   double y=A.xj()-B.xj();
   polar C=new polar(Ri(x,y),tetai(x,y));
   return C;
}

public void substract(polar B)
{
   double x=xi()-B.xi();
   double y=xj()-B.xj();
   read_cartesian(x,y);
}
 
public String toString()
{String s1=" R ="+R+" teta ="+teta+" radyan ";
return s1;}  

public static void outputwindow(String s)
{
String s1="polar class output window";	
JOptionPane.showMessageDialog(null,s,s1, JOptionPane.PLAIN_MESSAGE);	
}

}