|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
interface IUSB
{
public abstract boolean check();
public abstract void work();
}
//***************************************
class Computer
{
public void plugin(IUSB usb)
{
if(usb.check())
{
usb.work();
}
}
}
//*************************************
class Keyboard implements IUSB
{
public boolean check()
{
return true;
}
public void work()
{
System.out.println("Keyboard类==>开始进行码字");
}
}
//*****************************************
class Print implements IUSB
{
public boolean check()
{
return false;
}
public void work()
{
System.out.println("Print-->开始进行打印工作");
}
}
//**************************************
public class JavaDemo_0914_0006
{
public static void main(String[] args)
{
Computer computer=new Computer();
computer.plugin(new Keyboard());
computer.plugin(new Print());
}
}
|
|