You are on page 1of 1

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package shapee;

/**
*
* @author TALAL
*/
public class Sphere extends ThreeDimensionalShape{
private double radius;

public Sphere(double radius, String name, Color color) {


super(name, color);
if(radius<=0) {

throw new IllegalArgumentException("It should be greater than 0 ");

}
this.radius = radius;
}

public double getRadius() {


return radius;
}

public void setRadius(double radius) {


this.radius = radius;
}

public double Volume(){


return 4/3*Math.PI*radius*radius*radius;
}

@Override
public String toString() {
return super.toString();
}
}

You might also like