Page 283 - 6253
P. 283
public void shapeInfo() {
System.out.println("This is a shape 'Circle':");
super.shapeInfo();
System.out.println("\tradius = " + radius);
}
}
/**
* Created by Mykola Demchyna on 24.03.2018.
*/
public class Cube extends Shape implements IPerimeter, IVolume, IVertex {
private double side;
public Cube(double side, String color, Border borderStyle) {
super(color, borderStyle);
this.side = side;
}
public double getSide() {
return side;
}
public void setSide(double side) {
this.side = side;
}
@Override
public double getArea() {
return 6 * side * side;
}
@Override
public double getPerimeter() {
return 12 * side;
}
@Override
public double getVolume() {
return Math.pow(side, 3);
}
@Override
public int getNumberOfVertex() {
return 8;
}
@Override
public void shapeInfo() {
System.out.println("This is a shape 'Cube':");
super.shapeInfo();
System.out.println("\tside = " + side);
}
}
/**
* Created by Mykola Demchyna on 24.03.2018.
*/
public class Sphere extends Shape implements IVolume {
private double radius;
public Sphere(double radius, String color, Border borderStyle) {
super(color, borderStyle);
282