본문 바로가기
카테고리 없음

항해99 워밍업 4일차

by 수수남매 2023. 10. 9.
  • 오늘 공부한 것
    - JAVA Class 구현 실습

  • 고민했던 문제
    - Interface의 메서드를 여러 개의 상속 클래스에서 구현할 때 공통되는 코드를 줄일 수 있는 방법은?
    public interface Walkable {
        void walk(int x, int y);
    }
    
    public class Child extends Person implements Walkable, Runnable, Swimmable {
        
        @Override
        public void walk(int x, int y) {
            whoIs();
            System.out.println("speed: " + speed);
            this.x = x;
            this.y = y;
            System.out.println("walked to: " + getLocation());
        }
    }
    
    public class Parent extends Person implements Walkable, Runnable {
    
        @Override
        public void walk(int x, int y) {
            whoIs();
            System.out.println("speed: " + speed);
            this.x = x;
            this.y = y;
            System.out.println("walked to: " + getLocation());
        }
    }
        
    public class GrandParent extends Person implements Walkable {
    
        @Override
        public void walk(int x, int y) {
            whoIs();
            System.out.println("speed: " + speed);
            this.x = x;
            this.y = y;
            System.out.println("walked to: " + getLocation());
        }
    }
  • 알게 된 것
    - IntelliJ IDEA encoding(한글 깨짐) 문제 발생시 해결
      https://www.jetbrains.com/help/idea/encoding.html
      -> Editor>File Encodings 및 Editor>General>Console UTF-8로 변경