HolonSwitch.java 648 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package classes;
  2. public class HolonSwitch extends CpsObject {
  3. /*
  4. * True, if this wire is working (capable of carrying electricity), else
  5. * false
  6. */
  7. boolean active;
  8. public HolonSwitch(String ObjName) {
  9. super(ObjName);
  10. setState(false);
  11. }
  12. public HolonSwitch(String ObjName, String obj) {
  13. super(ObjName);
  14. super.setName(obj);
  15. setState(false);
  16. }
  17. public HolonSwitch(CpsObject obj) {
  18. super(obj);
  19. setState(((HolonSwitch)obj).getState());
  20. }
  21. public void switchState() {
  22. this.active = !active;
  23. }
  24. public boolean getState() {
  25. return this.active;
  26. }
  27. public void setState(boolean state){
  28. this.active = state;
  29. }
  30. }