Page 284 - 6253
P. 284
this.radius = radius;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
@Override
public double getArea() {
return 4 * Shape.PI * radius * radius;
}
@Override
public double getVolume() {
return 4.0 / 3 * Shape.PI * Math.pow(radius, 3);
}
@Override
public void shapeInfo() {
System.out.println("This is a shape 'Sphere':");
super.shapeInfo();
System.out.println("\tradius = " + radius);
}
}
/**
* Created by Mykola Demchyna on 24.03.2018.
*/
public interface IPerimeter {
double getPerimeter();
}
/**
* Created by Mykola Demchyna on 24.03.2018.
*/
public interface IVolume {
double getVolume();
}
/**
* Created by Mykola Demchyna on 24.03.2018.
*/
public interface IVertex {
public int getNumberOfVertex();
}
/**
* Created by Mykola Demchyna on 24.03.2018.
*/
public class Main {
public static void main(String[] args) {
Shape shapes[] = {
new Square(7.24, "red", Border.DOTTED),
new Circle(5.81, "green", Border.SOLID),
new Cube(6.75, "yellow", Border.DASHED),
new Sphere(6.39, "blue", Border.SOLID)
};
283