Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class Lamp { boolean isOn; public Lamp() { this.isOn = false; } public Lamp(boolean isOn) { ; } public void turnOn() { this.isOn = ;

class Lamp { boolean isOn; public Lamp() { this.isOn = false; } public Lamp(boolean isOn) { ; } public void turnOn() { this.isOn = ; } public void () { this.isOn = false; } public void flip() { this.isOn = ; } public isOn() { return this.isOn; } public void setLamp(boolean ) { this.isOn = isOn; } @Override public String toString() { String out; if (this.isOn) else out = String.format("%3s", "OFF"); return out; } @Override public boolean equals( obj) { Lamp other = (Lamp) obj; if (isOn != other.isOn) return false; return true; } }

image text in transcribed

Homework C-1: Get the Lamp class working. Write a Java program that creates an array of 30 Lamps that are randomly set to either On or Off. Write out all of the Lamps using 5 columns. Then flip the switch on each of the first 10 lamps, turn the next 10 off, and the final 10 on. Write out all the lamps again. Use a display method to write out the array of lamps

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

Methods of Delivery Guidelines for

Answered: 1 week ago