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

boolean powerState; String reallyCoolDescription; SpecialArtifact SpecialArtifact; SpecialArtifact(String name) i superCname); SpecialArtifact(String name, String description, boolean state, String otherDescription) super name, description); powerState = state; this. reallyCool Description = otherDescription; String examine) if CpowerStatetrue) return reallyCoolDescription; else return 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); } } }
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 corre

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site