アットウィキロゴ

Rectangle3D.java

public class Rectangle3D extends Rectangle implements ThreeDimensions {
	int depth;
 
	Rectangle3D(){
		super(5, 5);
		this.depth = 5;
	}
 
	Rectangle3D(int w, int h, int d){
		super(w, h);
		this.depth = d;
	}
 
	public int getVolume(){
		return super.getArea() * depth;
	}
	public int getSurface(){
		int sum;
 
		sum = width * height * 2;
		sum += depth * height * 2;
		sum += width * depth * 2;
 
		return sum;
	}
	public String toString(){
		return "[ 幅:" + this.width + " 高さ:" + this.height + " 奥行き:" + this.depth + " ]";
	}
}
 

タグ:

+ タグ編集
  • タグ:
最終更新:2012年01月31日 13:24