``````package tuxing;

import java.math.BigDecimal;

class cycle{
double r;
double pi=3.141592653589793;
public cycle(double r){

this.r=r;

}
public double c_Cycle(){

return 2*pi*r;
}
public double s_Cycle(){

return pi*r*r;
}
public void showInfo(){
System.out.println("圆形 "+"半径为："+r+"周长为："+c_Cycle()+"面积为:"+s_Cycle());
}
}
class square{
int l;
public square(int l){
this.l=l;
}
public double c_Square(){
double c;
c=4*l;
BigDecimal bd=new BigDecimal(c);
c=bd.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
return c;
}
public double s_Square(){
double s;
s=l*l;
BigDecimal bd=new BigDecimal(s);
s=bd.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
return s;
}
public void showInfo(){
System.out.println("正方形 "+"边长："+l+"周长为："+c_Square()+"面积为："+s_Square());
}

}
class triangle{
int l1;
int l2;
int l3;
public triangle(int l1,int l2,int l3){

this.l1=l1;
this.l2=l2;
this.l3=l3;

}
public double s_Triangle(){
double p=c_Triangle()/2;
}
public double c_Triangle(){
}
public void showInfo(){
if(l1+l2>l3&&l1-l2<l3)
System.out.println("三角形 "+"三边长分别为："+l1+","+l2+","+l3+","+"周长为："+c_Triangle()+"面积为："+s_Triangle());
else
System.out.println("Error Triangle");
}
}
public class Test {
public static void main(String[] args){
System.out.println("所有图形:");
cycle c1 =new cycle(5);
c1.showInfo();
square s2=new square(4);
s2.showInfo();
square s3=new square(5);
s3.showInfo();

triangle t4=new triangle(3,4,5);
t4.showInfo();
double c_sum;
double s_sum;
c_sum=c1.c_Cycle()+s2.c_Square()+s3.c_Square()+ t4.c_Triangle();
s_sum= c1.s_Cycle()+s2.s_Square()+ s3.s_Square()+ t4.s_Triangle();
System.out.println("周长和为："+c_sum);
System.out.println("面积和为"+s_sum);

}
}``````