public class TV {
Remote ctl;
String brand; //品牌属性
public TV(Remote c){
ctl = c;
}
//重载TV构造方法
public TV(Remote c, String brand) {
ctl = c;
this.brand = brand;
}
public void open(){ //开电视方法
if(ctl.getSwitchStation()== Remote.OPEN){
System.out.println("TV is openning...");
}
}
public void close(){ //关电视方法
if(ctl.getSwitchStation() == Remote.CLOSE){
System.out.println("TV is closing...");
}
}
public void showProgram(){ //播放节目方法
switch(ctl.getChannel()){
case 1:System.out.println("少儿频道");break;
case 2:System.out.println("体育频道");break;
case 3:System.out.println("音乐频道");break;
case 4:System.out.println("经济频道");break;
default:System.out.println("不能收看"+ctl.getChannel()+"频道");
}
}
}
评论0