Question: IN JAVA Design a class named Fan to represent a fan. The class contains the following attributes: Three constants named SLOW, MEDIUM, and FAST with

 IN JAVA Design a class named Fan to represent a fan.

IN JAVA

Design a class named Fan to represent a fan. The class contains the following attributes: Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speed. A data field named speed that specifies the speed of the fan (the default is SLOW). A data field named on that specifies whether the fan is on the default is false). A data field named radius that specifies the radius of the fan (the default is 5). A data field named color that specifies the color of the fan (the default is blue). The class also contains the following methods: The get() and set() methods for all private data fields. A no-arg constructor that creates a default fan. A method named toString() that returns a string description for the fan. If the fan is on, the method returns the fan speed, color, and radius. If the fan is not on, the method returns the fan color and radius along with the string "fan is oft". Write a test program that creates two Fan objects. Assign maximum speed, radius 10, color yellow, and turn it on to the first object. Assign radius 5, color blue, and turn it off to the second object. Display the objects by invoking their toString method. Sample Input/Output Fan 1 speed: 3, color: yellow, radius: 10.0 fan is on Fan 2 color: blue, radius: 5.0 fan is off

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 Databases Questions!