12 lines
367 B
Java
12 lines
367 B
Java
// exceptions/Switch.java
|
|
// ©2016 MindView LLC: see Copyright.txt
|
|
|
|
public class Switch {
|
|
private boolean state = false;
|
|
public boolean read() { return state; }
|
|
public void on() { state = true; System.out.println(this); }
|
|
public void off() { state = false; System.out.println(this); }
|
|
@Override
|
|
public String toString() { return state ? "on" : "off"; }
|
|
}
|