You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
953 B
25 lines
953 B
/**
|
|
* 基础题测试类
|
|
* 测试Printable接口和智能家居控制中心
|
|
*/
|
|
public class BasicTest {
|
|
public static void main(String[] args) {
|
|
System.out.println("===== 基础题测试 - 接口隔离原则 =====");
|
|
|
|
// 创建可打印设备
|
|
Printable printer = new Printer("HP LaserJet");
|
|
MultifunctionalDevice mfd = new MultifunctionalDevice("Canon Pixma");
|
|
|
|
// 创建智能家居控制中心
|
|
SmartHomeControlCenter controlCenter = new SmartHomeControlCenter("Main Hub");
|
|
|
|
// 测试打印功能
|
|
System.out.println("\n测试打印设备:");
|
|
controlCenter.controlPrintable(printer);
|
|
|
|
// 测试多功能设备
|
|
System.out.println("\n测试多功能设备:");
|
|
controlCenter.controlPrintable(mfd); // 通过Printable接口调用
|
|
controlCenter.controlMultifunctionalDevice(mfd); // 通过具体类型调用
|
|
}
|
|
} |