JAVA/예제

[JAVA] ch07-03. 객체 지향 3

밍글링글링 2017. 8. 22.
728x90
 
public class Ex03 {
    public static void main(String[] args){
        TVCR tvcr = new TVCR();
        tvcr.power();
        tvcr.play();
        tvcr.stop();
        System.out.println(tvcr);
    }
}

class TVCR extends Tv{
    VCR vcr = new VCR();
    int counter = vcr.counter;
    
    void play(){vcr.play();}
    void stop(){vcr.stop();}
    void rew(){vcr.rew();}
    void ff(){vcr.ff();}
}

class Tv{ 
    boolean power;
    int channel;
    
    void power(){power = !power;}
    void channelUp(){++channel;}
    void channelDown(){--channel;}
}

class VCR{
    boolean power;
    int counter=0;
    
    void power(){power=!power;}
    void play(){}
    void stop(){}
    void rew(){}
    void ff(){}
}

728x90

'JAVA > 예제' 카테고리의 다른 글

[JAVA] ch07-05. 객체 지향 5  (0) 2017.08.22
[JAVA] ch07-04. 객체 지향 4  (0) 2017.08.22
[JAVA] ch07-02. 객체 지향 2  (0) 2017.08.22
[JAVA] ch07-01. 객체 지향  (0) 2017.08.22
[JAVA] ch06-10. 배열 (Array) 10  (0) 2017.08.22

댓글