Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with this java program about classes and methods. I keep getting errors. Can someone do this problem so I can compare and
I need help with this java program about classes and methods.
I keep getting errors. Can someone do this problem so I can compare and contrast where I need to fix my issues. I will give positive feedback quickly if the program runs smoothly and is as described. Thank you.
CSCI 103L *9.8 (The Fan class) In this program, you will design a class named Fan to represent a fan. The class contains: Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speed. A private int data field named speed that specifies the speed of the fan (the default is SLOW). A private boolean data field named on that specifies whether the fan is on the default is false). A private double data field named radius that specifies the radius of the fan (the default is 5). A string data field named color that specifies the color of the fan (the default is blue ). Next, you will create a default constructor that creates a default fan. This will be followed by an overloaded constructor that receives and sets the fan speed, on value, radius, and color (Hint: create your overloaded constructor in this order). After that you will create 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 (Hint: IMPORTANT. Points will be deducted if steps are not properly followed). If the fan is not on, the method returns the fan color and radius along with the string Fan is off' in one combined string (Hint: IMPORTANT. Points will be deducted if steps are not properly followed). You must also create a separate test program (TestFans.java) that creates two Fan objects. = For the first object object name = fl), use the overloaded constructor to create the object. Assign the following: Speed: Fast, Radius: 10, Color: yellow, On: true For the second object object name = f2), use the overloaded constructor to create the object. Assign the following: Speed: Medium, Radius: 5, Color: blue, On: false Finally, display both objects values by invoking their toString method. The Output should resemble this sample output. Fan fi Fan speed = 3 Fan color = yellow Fan radius = 10.0 Fan 12 Fan color = blue Fan radius = 5.0 Fan is offStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started