day09_TelevisionTest2

육희영·2021년 10월 5일
0
package day09;

public class TelevisionTest2 {
	public static void main(String[] args) {
		//myTv와 yourTv는 별개의 객체를 가리킨다.
		Television1 myTv = new Television1();
		myTv.channel = 7;
		myTv.volume = 10;
		myTv.onOff = true;
		myTv.print();
		
		Television1 yourTv = new Television1();
		yourTv.channel = 9;
		yourTv.volume = 12;
		yourTv.onOff = true;
		yourTv.print();

	}
}

class Television2 {
	int channel; //채널 번호
	int volume; //볼륨
	boolean onOff; //전원 상태
	void print() {
		System.out.println("채널은 " + channel + "이고 볼륨은 " + volume + "입니다.");
	}
	int getChannel() {
		return channel;
	}
}

출력결과

채널은 7이고 볼륨은 10입니다.
채널은 9이고 볼륨은 12입니다.

0개의 댓글

관련 채용 정보