클래스

package chap_07;

public class BlackBox {
    String modelName;
    String resolution;
    int price;
    String color;

    static boolean canAutoReport = false;

    void autoReport() {
        if (canAutoReport){
            System.out.println("신고합니다.");
        } else {
            System.out.println("자동 신고 기능을 지원하지 않습니다.");
        }
    }

    void insertMemoryCard(int capacity) {
        System.out.println("메모리 카드가 삽입되었습니다.");
        System.out.println("용량은 " + capacity + "GB입니다.");
    }

    int getVideoFileCount(int type){
        if (type == 1){ // 일반 영상
            return 11;
        }
        else if ( type == 2) { // 이벤트 영상
            return 22;
        }

        return 10;
    }

    void record(boolean showDataTime, boolean showSpeed, int min) {
        System.out.println("녹화를 시작합니다.");
        if (showDataTime) {
            System.out.println("영상의 날짜 정보를 표시합니다.");
        }
        if (showSpeed) {
            System.out.println("영상의 속도 정보를 표시합니다.");
        }

        System.out.println("영상은" + min + "분 단위로 기록됩니다.");
    }

    void record(){
        record(true, true, 5);
    }

}
package chap_07;

public class _01_Class {
    public static void main(String[] args) {
        // 객체 지향 프로그래밍 (OOP : Object-Oriented Programing)
        // 유지보수 용이
        // 높은 재사용성

        String modelName = "까망이";
        String resolution = "FHD";
        int price = 20000;
        String color = "블랙";

        // 인스턴스 생성
        BlackBox bbox = new BlackBox();
        BlackBox bbox2 = new BlackBox();

    }
}
package chap_07;

public class _02_InstanceVariables {
    public static void main(String[] args) {
        BlackBox b1 = new BlackBox();
        b1.modelName = "까망이";
        b1.resolution = "FHD";
        b1.color = "블랙";
        b1.price = 20000;
    }
}
package chap_07;

public class _03_ClassVariables {
    public static void main(String[] args) {
        BlackBox b1 = new BlackBox();
        b1.modelName = "까망이";
        System.out.println(b1.modelName);

        BlackBox b2 = new BlackBox();
        b2.modelName = "하양이";
        System.out.println(b2.modelName);

        System.out.println("개발전----------------");
        System.out.println(b1.modelName + "자동 신고 기능" + b1.canAutoReport);
        System.out.println(b2.modelName + "자동 신고 기능" + b2.canAutoReport);

        BlackBox.canAutoReport = true;

        System.out.println("개발후----------");
        System.out.println(b1.modelName + "자동 신고 기능" + b1.canAutoReport);
        System.out.println(b2.modelName + "자동 신고 기능" + b2.canAutoReport);
    }
}
package chap_07;

public class _04_Method {
    public static void main(String[] args) {
        BlackBox b1 = new BlackBox();
        b1.modelName = "까망이";

        b1.autoReport();
        BlackBox.canAutoReport = true;
        b1.autoReport();

        b1.insertMemoryCard(256);

        // 일반 영상 type 1
        // 충돌 영상 type 2
        int fileCount = b1.getVideoFileCount(1);
        System.out.println("일반 영상 수 : " + fileCount + "개");

        fileCount = b1.getVideoFileCount(2);
        System.out.println("충돌 영상 수 : " + fileCount + "개");

    }
}