Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

how can I turn the boolean powerState from true to false Method name: String tou

ID: 3938387 • Letter: H

Question

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;

Explanation / Answer

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); } } }