目的は、2つの変数を取り、正しい範囲(> 0)にあるコンストラクタを作成することです。また、0可変半径が初期化されない可能性があるというエラーが表示されるのはなぜですか?
public class Cone {
private final double radius; // doesn't change after Cone is constructed
private final double height; // doesn't change after Cone is constructed
private double iceCreamHeight;
public Cone(double radius, double height){
iceCreamHeight = 0;
double r = radius;
double h = height;
if(r <=0 || h <=0 || iceCreamHeight <= 0){
r =1;
h=1;
System.out.println("ERROR Cone");
}
}
}
エラーメッセージはどうなっていますか? – shmosel