📄 frist.java
字号:
/*public abstract class Shape
{
private double x,y;
public void point()
{
x = 0;
y = 0;
}
abstract float area();
abstract float circumference();
}*/
class Circle extends Shape
{
public int r;
Circle(int r) {this.r=r;}
public double area() { return 3.14*r*r; }
public double circumference() { return 2*3.14*r; }
}
class Rectangle extends Shape
{
public double width,height;
Rectangle (double w, double h) { width=w; height=h;}
public double area() { return width*height; }
public double circumference() { return 2*(width+height); }
}
public class frist
{
public static void main( String args[] )
{
double area_total=0;
Circle c1 = new Circle(3);
Circle c2 = new Circle(4);
Circle c3 = new Circle(5);
Rectangle r1 = new Rectangle(3.0,4.0);
Rectangle r2 = new Rectangle(5.0,6.0);
Rectangle r3 = new Rectangle(7.0,8.0);
Object sh[]=new Object[6];
sh[0]=c1;
sh[1]=c2;
sh[2]=c3;
sh[3]=r1;
sh[4]=r2;
sh[5]=r3;
for(int i=0;i<6;i++)
{
area_total+=((Shape)sh[i]).area();
}
System.out.println("The total of area is "+area_total+"\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -