这个程序怎么测试
package Romote;
/*
* 功能:通过遥控控制客厅电视,卧室电灯
* 类:
* 遥控器类(接口)
* 成员方法:
* 扩展:
* 客厅电视:
* 成员方法:打开电视
* 关闭电视
* 卧室电灯:
* 成员方法:打开电灯
* 关闭电灯
*
*/
interface Command { // 接口类Command,为电灯和电视提供开、关的命令集
abstract void on(); // 电器打开
abstract void off(); // 电器关闭
}
class Light { // 电灯类
private int degree;
public int getturnLight(){
return degree;
}
public void setturnLight(int degree) {// 调整灯光亮度,0表示关灯,100表示亮度最大
this.degree=degree;
if(degree==0){
System.out.println("电灯关闭");
}else if(degree==100){
System.out.println("电灯亮度达到最大");
}
}
}
class TV {
private int channel;
public int getChannel(){
return channel;
}
public void setChannel(int channel) {
this.channel=channel;
if(channel==0){
System.out.println("电视关闭");
}else if(channel==1){
System.out.println("打开电视");
}
}
}
class romoteController {
protected Command[] commands = new Command[4];
public void onPressButton(int button) {// 按钮被按下时,执行命令对象的命令
if (button % 2 == 0)
commands[button].on();
else
commands[button].off();
}
public void setCommand(int button, Command command) {
commands[button] = command; // 设置每个按钮应对应得命令对象
}
}
class LightCommand implements Command {
protected Light light; // 指向要控制的电灯对象
public void on() {
System.out.println("电灯打开");
}
public void off() {
System.out.println("电灯关闭");
}
public LightCommand(Light light) {
this.light=light;
light.getturnLight();
light.setturnLight(100);
}
}
class TVCommand implements Command {
protected TV tv;
protected int channel;
public void on() {
System.out.println("电视打开");
}
public void off() {
System.out.println("电视关闭");
}
public TVCommand(TV tv, int channel) {
tv.getChannel();
tv.setChannel(0);
}
}
public class Romote{
public static void main(String[] args) {
//创建对象
// Command c=new LightCommand();
// Command c=new TVCommand();
// romoteController r=new romoteController();
}
}