building.java~9~

来自「《深入浅出设计模式》的完整源代码」· JAVA~9~ 代码 · 共 23 行

JAVA~9~
23
字号
package securitysystem;//大楼类:public class Building extends SecurityZone {  public Building(String name) {    super(name);  }  boolean handleNotification(int measurement, Sensor sensor) {       return false;  }  void fireAlarm(SecurityZone zone,Sensor sensor) {    if (zone instanceof Area) {        // Turn on sprinklers in surrounding areas        // Don't call super.fireAlarm because that will turn on the        // sprinkler for the whole warehouse.        System.out.println(this.name+"栋大楼发生火警");        if (getParent() != null)          getParent().fireAlarm(zone,sensor);        return;    } // if    super.fireAlarm(zone,sensor);}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?