Sphere
import java.util.*;
class Sphere{
//data members
static int count = 0;
//instance
static double radius;
//coordinates
double xCenter;
double yCenter;
double zCenter;
//constructor
Sphere(double radiusR, double x, double y, double z){
radius = radiusR;
xCenter = x;
yCenter = y;
zCenter = z;
//increment instance of sphere
++count;
}
//number of objects
static int getCount(){
return count;
}
//compute volume of sphere
static double getVolume(){
return 4.0/3.0*Math.PI*Math.pow(radius,3);
}
}
No comments:
Post a Comment