mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-17 04:51:58 -05:00
update:demo4
This commit is contained in:
26
com/study/demo4/HomeAppliance.java
Normal file
26
com/study/demo4/HomeAppliance.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.study.demo4;
|
||||
|
||||
abstract class HomeAppliance implements SmartDevice {
|
||||
protected String name;
|
||||
protected boolean isOn;
|
||||
|
||||
public HomeAppliance(String name) {
|
||||
this.name = name;
|
||||
this.isOn = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void turnOn() {
|
||||
isOn = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void turnOff() {
|
||||
isOn = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return name + " is " + (isOn ? "ON" : "OFF");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user