Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Java

Design a class named Fan to represent a fan. The class should have: 1. Three constants named SLOW, MEDIUM, and FAST with the values 1, 2 ,and 3 to denote the fan speed. 2.A private int data field named speed that specifies the speed of the fan (the default is SLOW) 3.A private boolean data field named on that specifies whether the fan is on (the default is false). 4. A private double data field named radius that specifies the radius of the fan (the default is 5). 5.A String data field named color that specifies the color of the fan (the default is blue). 6. The accessor and mutator methods for all four data fields. 7. A no-arg constructor that creates a default fan. 8. 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 the fan color and radius along with the string “fan is off” in one combine String. 👇🏻 https://code.sololearn.com/cr5kj5nlD1LC/?ref=app

4th May 2021, 4:52 AM
Decoder 👩‍💻
2 Answers
0
import java.util.*; public class Fan { public static void main (String [] args){ final int SLOW = 1; final int MEDIUM = 2; final int FAST = 3; private int speed = SLOW; private boolean on = false; private double radius=5; private String color = "blue"; }
4th May 2021, 5:16 AM
Decoder 👩‍💻
0
Like this
4th May 2021, 5:17 AM
Decoder 👩‍💻