import java.lang.Math;

public class NewtonMethod {
public static void main(String args[]){
double x = 0.785;
while (true){
double x2 = x * 2;
double xN = x - (Math.cos(x2) - x2 + 1)/(- 2 * Math.sin(x2) - 2);
if (xN >= x){
break;
}
x = xN;
}
System.out.println(x);
}
}

これを複数のクラスを定義して作成する方法に変えるにはどうしたらいいのでしょうか?