本帖最后由 工善器 于 2013-11-2 08:26 编辑
package en.itcast.java.tools;
interface PCI
{
void powerOn();
void swapData();
void Pluge();
}
class Shengka implements PCI
{
public void powerOn(){}
public void swapData(){}
public void pluge()
{
System.out.println("声卡安装到了电脑上");
}
}
class Wangka implements PCI
{
public void powerOn(){}
public void swapData(){}
public void pluge()
{
System.out.println("网卡安装到了电脑上");
}
}
class ZhuBan
{
public void usePCI(PCI p)
{
p.Pluge();
}
}
public class MainBoard
{
public static void main(String[] args)
{
ZhuBan m=new ZhuBan();
PCI s=new Shengka();
PCI w=new Wangka();
m.usePCI(w);
m.usePCI(s);
}
}
|
|