Question: Create a class called CeilingFan ( in CeilingFan.java ) that includes a boolean field to indicate whether or not the fan is on , and

Create a class called CeilingFan (in CeilingFan.java) that includes a boolean field to indicate whether or not the fan is on, and an integer field for the speed setting of the fan (1 through 4). Include get methods for each field. A method called setSpeed() sets the value of the speed setting and a method called togglePower() turns the fan on and off. A method called getEnergyUse() returns the amount of energy currently consumed by the fan (in watts). If the fan is not on, it uses 0 watts, regardless of the speed setting. If the fan is on, it uses energy based on the speed setting:
15 watts
35 watts
55 watts
75 watts
Next create a program in TestCeilingFan.java that demonstrates the CeilingFan class by creating an instance of the class and outputting power consumption in a variety of situations (on/off & speed settings). This program does not require user input.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!