//这是无参的
package com.LEE;
public abstract class Shape {
public abstract void perimeter();
public abstract void area();
}
//************************************************
package com.LEE;
public class Rectangle extends Shape {
int a=1,b=2;
@Override
public void perimeter() {
// TODO Auto-generated method stub
System.out.println("矩形周长为"+2*(a+b));
}
@Override
public void area() {
// TODO Auto-generated method stub
System.out.println("矩形面积为"+a*b);
}
}
//*************************************************
package com.LEE;
public class Circle extends Shape {
int r=2;
@Override
public void perimeter() {
// TODO Auto-generated method stub
System.out.println("圆形周长是"+(2*3.14*r));
}
@Override
public void area() {
// TODO Auto-generated method stub
System.out.println("圆形面积是"+(3.14*r*r));
}
}
//****************************************************
package com.LEE;
public class Initial {
public static void main(String[] args){
Shape Rec=new Rectangle();
Shape Cir=new Circle();
Rec.perimeter();
Rec.area();
Cir.perimeter();
Cir.area();
}
}