2、根据课堂PPT上的图示的类的结构和给定代码框架TestShape,完成该下面的程序:
abstract class Shape {
protected int x, y, k;
protected double m;
abstract public double getPerimeter();
abstract public double getArea();
public void display(){
System.out.print("The perimeter="+getPerimeter()+"\t and the area="+getArea());
}
}
class Circle extends Shape{// 完成类的定义
Circle(int r){
// 写语句
}
public double getPerimeter(){
// 写语句
}
public double getArea(){
// 写语句
}
public void display(){
// 写语句
}
}
class Square extends Shape{
Square(int a, int b){
// 写语句
}
public double getPerimeter(){
// 写语句
}
public double getArea(){
// 写语句
}
public void display(){
System.out.println("矩形边长分别为"+x+"和"+y+":");
super.display();
System.out.println();System.out.println();
}
}
class Cubic extends Shape{
Cubic(int a, int b, int c){
// 写语句
}
public double getPerimeter(){
// 写语句
}
public double getArea(){
// 写语句
}
public double getVolume(){
// 写语句
}
public void display(){
System.out.println("立方体边长分别为"+x+"、"+y+"和"+k+":");
// 写语句
}
}
public class TestShapes {
abstract class Shape { protected int x, y, k; protected double m; abstract public double getPerimeter(); abstract public double getArea(); public void display() {System.out.println("The perimeter=" + getPerimeter() + "\t and the area="
+ getArea()); }}class Circle extends Shape { // 完成类的定义 Circ...