import javax.swing.*;

public class polar
{
protected double R,tetha;

//constructor methods

public polar()
{R=0;tetha=0;}

public polar(double Ri,double tethai)
{R=Ri;tetha=tethai;}

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

public void polar_gir(double Ri,double tethai)
{R=Ri;tetha=tethai;}

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

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

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

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

public void read_as_cartesian(double xi,double xj)
{
R=Math.sqrt(xi*xi+xj*xj);
tetha=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),tethai(x,y));
   return C;
}

public void add(polar A)
{
   double x=xi()+A.xi();
   double y=xj()+A.xj();
read_as_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),tethai(x,y));
   return C;
}

public void substract(polar B)
{
   double x=xi()-B.xi();
   double y=xj()-B.xj();
   read_as_cartesian(x,y);
}
 
public String output()
{String s1=" R ="+R+" tetha ="+tetha+" radian ";
return s1;}  

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

}