package interfaceDemo;
interface Equipment_specifications{
void DoWork();
}
class MBorad{//主板
private static int index;//定义一个变量
private static Equipment_specifications[] es=new Equipment_specifications[6];//创建一个长度为6的数组 public static void pluginIn( Equipment_specifications usb){
if(index==es.length){
System.out.println("设备接口已经插满!");
return;
}
es[index]=usb;
index++;
}
public static void Operation() {
// TODO 自动生成的方法存根
for(Equipment_specifications usb : es){
if(usb != null){
usb.DoWork();
}
}
}
}
class Mouse implements Equipment_specifications{//USB鼠标 @Override
public void DoWork() {
// TODO 自动生成的方法存根
System.out.println("我在实现点击!");
} }
class Printer implements Equipment_specifications{//USB打印机 @Override
public void DoWork() {
// TODO 自动生成的方法存根
System.out.println("我在实现打印文字!");
} }
public class MotherBorad { public static void main(String[] args) {
// TODO 自动生成的方法存根
MBorad.pluginIn(new Printer());
MBorad.pluginIn(new Mouse());
MBorad.pluginIn(new Mouse());
MBorad.pluginIn(new Mouse());
MBorad.pluginIn(new Mouse());
MBorad.pluginIn(new Mouse());
MBorad.pluginIn(new Mouse());
MBorad.Operation(); } }

最新文章

  1. 关于Android多项目依赖在Eclipse中无法关联源代码的问题解决
  2. [webpack] webpack-dev-server介绍及配置
  3. jQuery Mobile 导航栏
  4. JAVA 设计模式 备忘录模式
  5. 关于jquery自带动画效果的stop()问题
  6. 剑指Offer 变态跳台阶
  7. EI表达式和JSTL
  8. PLSQL_基础系列08_操作符标LPAD / TRUNC / DECODE / TRIM / INSTR(案例)
  9. C#三种判断数据库中取出的字段值是否为空(NULL) 的方法
  10. 基于visual Studio2013解决面试题之0604O(1)时间复杂度删除链表节点
  11. [UWP小白日记-9]页面跳转过度动画(二)
  12. Spring 数据库连接(Connection)绑定线程(Thread)的实现
  13. Normalize.css & Reset
  14. CSS选择器、样式、盒模型
  15. mvn package
  16. iOS开发-带Placeholder的UITextView实现
  17. 学习Java 采取令牌的方式避免重复提交
  18. BZOJ1064 NOI2008假面舞会(dfs树)
  19. 配置Spring Boot通过@ConditionalOnProperty来控制Configuration是否生效
  20. Kali之——解决物理机U盘安装Kali Linux2018.1,光驱无法加载问题

热门文章

  1. STL的erase函数和lower_bound
  2. dbca 快速健建库
  3. New Year and Counting Cards
  4. Visualforce入门第五篇_2017.3.1
  5. DropShadowEffect导致下拉框控件抖动
  6. div 遮罩层 弹窗
  7. extjs控制器调用其他视图的函数实现控件赋值。
  8. 由于簇计数比预计的高,格式化操作无法完成——Allocation Unit Size Adjustments for Larger NTFS Volumes.
  9. iperf 网络测速
  10. java代码equals方法