package com.test.adapter;
public class Computer {
public void show(USB usb){
usb.recive();
System.out.println("电脑显示输入的数据");
}
public static void main(String[] args) {
Computer c = new Computer();
USB u = new USBAdapter();
c.show(u);
}
}
class KeyBoard{
public void input(){
System.out.println("键盘输入数据");
}
}
/**
* 适配器接口
*/
interface USB{
public void recive();
}
/**
* 具体的适配器
*/
class USBAdapter extends KeyBoard implements USB{
public void recive() {
System.out.println("我是USB适配器,我使圆口的键盘能和USB接口电脑连接");
super.input();
}
}
package com.test.adapter;
public class Computer {
public void show(USB usb){
usb.recive();
System.out.println("电脑显示输入的数据");
}
public static void main(String[] args) {
Computer c = new Computer();
KeyBoard k = new KeyBoard();
USB u = new USBAdapter(k);
c.show(u);
}
}
class KeyBoard{
public void input(){
System.out.println("键盘输入数据");
}
}
/**
* 适配器接口
*/
interface USB{
public void recive();
}
/**
* 具体的适配器
*/
class USBAdapter implements USB{
private KeyBoard k;
public USBAdapter(KeyBoard k) {
this.k = k;
}
public void recive() {
System.out.println("我是USB适配器,我使圆口的键盘能和USB接口电脑连接");
k.input();
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有