Rectangle类中包含一个表示高的double型成员变量;
构造方法Cuboid(double length,double width,double,height)
package com.company;
public class Rectangle extends Shape{
private double length;
private double height;
public Rectangle(){
this(10,5);
}
public Rectangle(double length,double height){
super("矩形"); // 调用父类的构造方法
this.length = length;
this.height = height;
}
package com.company;
public class test74Square extends Shape {
private double radius;
public test74Square(double radius){
this.radius = radius;
}
public void setRadius(double radius){
this.radius = radius;
}
public double getRadius(){
return radius;
}
@Override
public double getPerimeter(){
return 2 * Math.PI * radius;
}
@Override
public double getArea(){
return Math.PI * radius * radius;
}
public static void main(String[] args) {
test74Square test74Square = new test74Square(1);
System.out.println(test74Square.getPerimeter());
}
}