私はとても迷っています。私はこのプログラムを持っています。このプログラムは、半径と高さのパラメータを持つ円柱を構築することができます。次に、半径と出力面積と体積を取得および設定するためのさまざまなメソッドを呼び出すことができます。静的で非静的なメソッドが静的に使用されていることについてはエラーがなく、私のメインに何も置くことができないので、私は渡されません。私はその意味が分からない。私は実際に他の人のコードをコンパイラにコピーして、同じエラーが出ます。私はいくつかの設定を台無しにしましたか?私はこれがおそらくスタックオーバーフローのための初歩的なものであることを知っていますが、私はこの時点で絶望的です。Java - シリンダープログラム - メインを使用することができません
public class Miller_A03Q1 {
public static void main(String[] args) {
Cylinder cylinder1 = new Cylinder(1,17);
Cylinder cylinder2 = new Cylinder(3,8);
Cylinder cylinder3 = new Cylinder(2,12);
Cylinder cylinder4 = new Cylinder (1,14);
}
public class Cylinder{
private double radius = 0.0;
private double height= 0.0;
private double area = 0.0;
private double volume=0.0;
private String shape = "cylinder";
public Cylinder(double r,double h){
this.radius = r;
System.out.print(r);
this.height = h;
System.out.print(h);
}
public double getVolume(){
double volume = 3.14 * radius * radius * height;
return volume;
}
public double getArea(){
double circumference = 3.14 * 2 * radius;
double circleArea = 3.14 * radius * radius;
double area = (2 * circleArea) + (circumference * this.height);
return area;
}
public double getRadius(){
return this.radius;
}
public double getHeight(){
return this.height;
}
public void setHeight(double h){
this.height = h;
}
public void setRadius(double r){
this.radius = r;
}
@Override
public String toString(){
return this.shape + this.radius + this.height+ this.volume + this.area;
}
}
}
は 'のpublic staticクラスシリンダー{' ....あなた 'Cylinder'をお試しください「Miller_A03Q1」の – bradimus
'Miller_A03Q1'と' Cylinder'を2つの別々のクラスとして作成することもできます。 – Blobonat