编译还是通不过,希望高手们能亲自测试下并给出错误的解决办法,不甚感激
程序代码:class Trangle
{
double sideA,sideB,sideC,area,length;
boolean boo;
public Trangle(double a,double b,double c)
{ sideA=a;
sideB=b;
sideC=c;
if(a+b>c||a+c>b||b+c>a)
{ boo=ture;
}
else
{ boo=false;
}
}
double getLength()
{ length=sideA+sideB+sideC;
return length;
}
public double getArea()
{ if(boo)
{ double p=(sideA+sideB+sideC)/2.0;
area=Math.sqrt(p*(p-sideA)*(p-sideB)*(p-sideC));
return area;
}
else
{ System.out.println("不是一个三角形,不能计算面积");
return 0;
}
}
public void setABC(double a,double b,double c)
{ sideA=a;
sideB=b;
sideC=c;
if(a+b>c||a+c>b||b+c>a)
{ boo=ture;
}
else
{ boo=false;
}
}
}
class Lader
{ double above,bottom,height,area;
Lader(double a,double b,double h)
{ above=a;
bottom=b;
height=h;
}
double getArea()
{ area=(above+bottom)*height/2.0;
return area;
}
}
class Circle
{ double radius,area;
Circle(double r)
{ radius=r;
}
double getArea()
{ area=3.14*radius*radius;
return area;
}
double getLength()
{ length=2.0*3.14*radius;
return length;
}
void setRadius(double newRadius)
{ radius=newRadius;
}
double getRadius()
{ return radius;
}
}
public class AreaAndLength
{ public static void main(String args[])
{ double length,area;
Circle circle=null;
Trangle trangle;
Lader lader;
circle=new Circle(double r);
trangle=new Trangle(double a,double b,double c);
lader=new Lader(double a,double b,double h);
length=circle.getLength();
System.out.println("圆的周长:"+length);
area=circle.getArea();
System.out.println("圆的面积:"+area);
length=trangle.getLength();
System.out.println("三角形的周长:"+length);
area=trangle.getArea();
System.out.println("三角形的面积:"+area);
area=lader.getArea();
System.out.println("梯形的面积:"+area);
trangle.Trangle(12.0,34.0,1.0);
area=trangle.getArea();
System.out.println("三角形的面积:"+area);
length=trangle.getLength();
System.out.println("三角形的周长:"+length);
}
}
[[it] 本帖最后由 littlebee 于 2008-10-4 00:59 编辑 [/it]]