글쓴이 :제발 답변주세요. 2000년 5월 18일 00:52:22
In Reply to: 제발... posted by 최기섭 on 2000년 5월 17일 13:48:23:
답변 정말 감사합니다.정말 도움됬어요.
어떻게 감사드려야할지...
그런데 또 에러나요.
can't make a static reference to nonstatic
variable tri1 in class Triangle.
if(tri1.is right(line1,line2,line3)
왜 나는지 모르겠어요.제발 답변주세요.
import java.io.*;
class Triangle {
Triangle_control tri1 = new Triangle_control();
public static void main (String[] args) throws IOException {
BufferedReader stdin = new BufferedReader
(new InputStreamReader (System.in));
int line1, line2, line3;
//세 변을 입력받는다.
System.out.println ("삼각형의 세 변을 입력하시오.");
System.out.println ("line1 :");
line1 = Integer.parseInt(stdin.readLine());
System.out.println ("line2 :");
line2 = Integer.parseInt(stdin.readLine());
System.out.println ("line3 :");
line3 = Integer.parseInt(stdin.readLine());
//삼각형의 타입을 결정한다.
if (tri1.is_right( line1, line2, line3))
System.out.println ("직각 삼각형입니다.");
if (tri1.is_scalene( line1, line2, line3))
System.out.println ("두변의 길이가 모두 다르다.");
if (tri1.is_isosceles( line1, line2, line3))
System.out.println ("정확히 두 변의 길이가 같다.");
if (tri1.is_equilateral( line1, line2, line3))
system.out.println ("세 변의 길이가 모두 같다.");
}//클래스 Triangle
//삼각형의 타입 조건을 설정해준다.
class Triangle_control {
int l1,l2,l3;
public boolean is_right(int line1,int line2,int line3){
boolean success = false;
if (line1 > line2) { l3 = line1; l1 = line2;}
else { l3 = line2; l1 = line1; }
if (line3 > line3a) { l2 = line3a; l3 = line3; }
else { l2 = line3; }
if ((l3*l3) == (l2*l2 + l1*l1))
success = true;
return success;
}//직각 삼각형
public boolean is_scanlene(int line1,int line2,int line3) {
boolean success = false;
if ((line1 != line2) && (line2 != line3) && (line1 != line3))
success = true;
return success;
}//두 변의 길이가 모두 다르다
public boolean is_isosceles(int line1,int line2,int line3){
boolean success = false;
if ((line1 == line2) || (line2 == line3) || (line1 == line3))
success =true;
return success;
}//정확히 두 변의 길이가 같다.
public boolean is_equilateral(int line1,int line2,int line3){
boolean success = false;
if ((line1 == line2 ) && (line2 == line3) && (line1 == line3))
success = true;
return success;
}//세 변의 길이가 모두 같다.
}
}