Question: Thanks for the help! Design a class named Fan to represent a fan. The class contains: Three constants named SLOW, MEDIUM, and FAST with values

 Thanks for the help! Design a class named Fan to representa fan. The class contains: Three constants named SLOW, MEDIUM, and FAST

Thanks for the help!

Design a class named Fan to represent a fan. The class contains: Three constants named SLOW, MEDIUM, and FAST with values 1, 2, and 3 to denote the fan speed. An int data field named speed that specifies the speed of the fan (default SLOW) A boolean data field named on that specifies whether the fan is on (default is false). A double data field named radius that specifies the radius of the fan (default 5) A string data field named color that specifies the color of the fan (default blue) An int static data field named numberOfObjects (default 0) A no-arg constructor that creates a default fan. A constructor with four parameters (speed, on, radius and color) with the appropriate data types that will be able to a fan object with user desired speed, on-off status, radius and color The get(accessor) and set(mutator) methods for all four data fields: speed, on, radius and color A static getNumberOfObjects method to return the data field numberOfObjects. 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 in one combined string. If the fan is not on, the method returns fan color and radius along with the string "fan is off" in one combined string. Requirements . Draw the UML diagram for the Fan class. Then implement the Fan class. 2. When implementing the Fan class, use this keyword to refer the class's hidden instance variable within set methods and to invoke an overloaded constructor within the constructor with no argument. 3. Write a test program, the TestFan class, that creates two Fan objects and do the following tasks a. Assign maximum speed, radius 10, color yellow, and turn it on for the first fan

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!