package date_1217;
public class Circle extends Shape {
float r=2.5f;
public float zhouChang() {
System.out.println("圆形的周长"+2*Math.PI*r);
return (float)(2*Math.PI*r);
}
public float mianJi() {
System.out.println("圆形的面积"+Math.PI*r*r);
return (float)(Math.PI*r*r);
}
}
public class Circle extends Shape {
float r=2.5f;
public float zhouChang() {
System.out.println("圆形的周长"+2*Math.PI*r);
return (float)(2*Math.PI*r);
}
public float mianJi() {
System.out.println("圆形的面积"+Math.PI*r*r);
return (float)(Math.PI*r*r);
}
}
2015-12-17
package date_1217;
public class Rectangle extends Shape {
float l=3.0f;
float w=7.0f;
public float zhouChang() {
System.out.println("矩形的周长"+2*l+2*w);
return 2*l+2*w;
}
public float mianJi() {
System.out.println("矩形的面积"+l*w);
return l*w;
}
}
public class Rectangle extends Shape {
float l=3.0f;
float w=7.0f;
public float zhouChang() {
System.out.println("矩形的周长"+2*l+2*w);
return 2*l+2*w;
}
public float mianJi() {
System.out.println("矩形的面积"+l*w);
return l*w;
}
}
2015-12-17
package date_1217;
public abstract class Shape {
public abstract float zhouChang();
public abstract float mianJi();
}
public abstract class Shape {
public abstract float zhouChang();
public abstract float mianJi();
}
2015-12-17