how can I turn the boolean powerState from true to false Met
how can I turn the boolean powerState from true to false
Method name: String touch ( )
Responsibility: Changes state (e.g. open/close, on/off) and returns corresponding touch description
Solution
public class SpecialArtifact extends Artifact { String powerOn, powerOff; boolean powerState; SpecialArtifact() { this.powerState = true; } public void toggle() { this.powerState = !this.powerState; } SpecialArtifact(String aName) { super(aName); } String examine() { this.toggle(); if (!powerState) // making paper glow return this.description; else return this.powerOff; } public void touch() { if (!powerState) { System.out.println(this.powerOn); } else { System.out.println(this.description); } } }