커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
1-16 수업 실습중 에러
파이썬 문법 뽀개기
1주차
북마크
한*윤
댓글
3
추천
0
조회수
13
조회수
13
답변 완료
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요
  튜터님은 지우고 하라고 하셨는데 나중에 적어놓은 코드를 다시보고싶어서 호크를 추가해 만들었더니 오류가 뜹니다. 이유를 알수있을까요?

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.

튜터님은 지우고 하라고 하셨는데 나중에 적어놓은 코드를 다시보고싶어서 호크를 추가해 만들었더니 오류가 뜹니다. 이유를 알수있을까요?

static과 메인함수 마지막 } 에 빨간줄이 그어져있습니다.







//추상클래스,인터페이스
//추상클래스는 자식클래스없이 인스턴스생성x Animal과 Dog에서 Animal타입으로 new Dog o,new animal x
//인터페이스는 객체의 특정 행동의 특징을 정의, 접근제어자 return type method 이름만 정의, 내용은없음
//인터페이스에 존재하는 상세내용을 반드시 구현
abstract  class Bird{
    private  int x,y,z;
    void fly(int x, int y, int z){
        printLocation();
        System.out.println("이동합니다.");
        this.x = x;
        this.y = y;
        if(flyable(z)) {
            this.z = z;
        }else {
            System.out.println("그 높이로는 날 수 없습니다.");
        }
        printLocation();
    }
    abstract boolean flyable(int z); //{} 추상클래스는 body를 가질수없음
    public void printLocation(){
        System.out.println("현재위치 ("+x+","+y+","+z+")");
    }
}
class  Pigeon extends Bird{       //implement method option+enter

    @Override
    boolean flyable(int z) {
        return z < 10000;
    }
}
class Peacock extends Bird{    //위와 동일 option+enter

    @Override
    boolean flyable(int z) {
        return false;
    }
}
interface Flyable{
    void fly(int x, int y, int z);
}
class Hawk implements Flyable{     //option+enter
    private  int x,y,z;
    @Override
    public void fly(int x, int y, int z) {
        printLocation();
        System.out.println("이동합니다.");
        this.x = x;
        this.y = y;
        this.z = z;

        printLocation();

    }
    public void printLocation(){
        System.out.println("현재위치 ("+x+","+y+","+z+")");
}

public class Java1_16 {
    public static void main(String[] args) {
        //Bird bird = new Bird()  //abstract라 불가능
        Bird pigeon = new Pigeon();
        Bird peacock = new Peacock();
        System.out.println("---비둘기---");
        pigeon.fly(1, 1, 3);
        System.out.println("---공작새---");
        peacock.fly(1, 1, 3);
        System.out.println("---비둘기---");
        pigeon.fly(3, 3, 30000);
        Flyable hawk = new Hawk();
        hawk.fly(1, 2, 3);
    }
}

Static declarations in inner classes are not supported at language level '8'

'}' expected



취소
 공유
취소
댓글 0
댓글 알림
나의얼굴