package com.study.demo4; import java.util.ArrayList; import java.util.List; public class TestControl { public static void main(String[] args) { HomeController controller = new HomeController(); // 创建设备 SmartLight light = new SmartLight("Living Room Light"); SmartAirConditioner ac = new SmartAirConditioner("Bedroom AC"); SmartMasher masher = new SmartMasher("Kitchen Masher"); // 添加到控制器 controller.addDevice(light); controller.addDevice(ac); controller.addDevice(masher); // 测试设备状态 light.turnOff(); ac.turnOff(); masher.turnOn(); // 查询状态 System.out.println(controller.getDeviceStatus("Living Room Light")); System.out.println(controller.getDeviceStatus("Bedroom AC")); System.out.println(controller.getDeviceStatus("Kitchen Masher")); System.out.println(controller.getDeviceStatus("Non-existent Device")); } }