cannot find symbol
写有三角类如下代码:class triangle {
double a;
double b;
double c;
public triangle(double a ,double b,double c){
if((a+b>c)&&(a+c>b)&&(b+c>a)&&(a-c<b)&&(a-b<c)&&(b-c<a)){
this.a=a;
this.b=b;
this.c=c;
}
else {
System.out.println("输入边长有错");
}
}
public double GetCircle(){
return (a+b+c);
}
public double GetArea(){
double p;
p=(a+b+c)/2.0;
return (Math.sqrt(p*(p-a)*(p-b)*(p-c)));
}
}
class Tprism extends triangle{
double height;
public Tprism (double a ,double b,double c,double height){
if((a+b>c)&&(a+c>b)&&(b+c>a)&&(a-c<b)&&(a-b<c)&&(b-c<a)){
this.a=a;
this.b=b;
this.c=c;
this.height=height;
}
else {
System.out.println("输入边长有错");
}
}
}
class exp1{
public static void main(String [] args){
triangle r = new triangle(3.0,4.0,5.0);
Tprism c=new Tprism(3.0,4.0,5.0,6.0);
System.out.println("三角形的周长" + r.GetCircle());
System.out.println("三角形的面积"+r.GetArea());
System.out.println("三棱柱的底面积"+c.GetCircle());
System.out.println("三棱柱的底周长"+c.GetArea());
System.out.println("三棱柱的体积"+c.GetArea()*c.height);
}
}
但是编译如下:
--------------------Configuration: question1 - JDK version 1.5.0_02 <Default>--------------------
E:\question1\exp1.java:29: cannot find symbol
symbol : constructor triangle()
location: class triangle
public Tprism (double a ,double b,double c,double height){
^
1 error
Process completed.
求正解,请赐教