class TriangleX
{
double bottom;
double high;
public void TriangleX(double bt, double hi)
{
bottom=bt;
high=hi;
}
public double triangleMyeon()
{
return bottom*high/2;
}
public void yeonSanResult()
{
System.out.println("밑변 : "+bottom+" "+"높이 : "+high);
System.out.println("삼각형의 넓이 : "+triangleMyeon());
}
}
class TriangleY
{
public static void main(String[] args)
{
TriangleX sanja1 = new TriangleX(4.2,6.2);
TriangleX sanja2 = new TriangleX(7.4,12.6);
System.out.println("첫번째 삼각형의 넓이");
sanja1.yeonSanResult();
System.out.println("두번째 삼각형의 넓이");
sanja2.yeonSanResult();
}
}
오류가 두개가 떳는데 두개가 인스턴스 생성에 대한 오류였습니다.
대강 해석해보자면 TriangleX클래스안에서 저런 양식을 적용할 수 없다는 내용같아요.
제가 보다시피 기본적인것에도 헤매는 초보자라..ㅠㅠ
왜 저게 막히는지 이해가 전혀 되지 않습니다. ㅠㅠ 왜 오류가 뜨는거죠?
오류 원본 :
Triangle.java:29: errors: constructor TriangleX in class TriangleX cannot be applied to given types;
TriangleX sanja1 = new TriangleX(4.2, 6.2)
같은 방식으로 그 밑에 인스턴스생성문도 오류가 났습니다.