Here are is assignment question: The Fan Class
• Three static constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speeds.
• A private int data filed named “speed” that specifies the speed of the fan, default to slow.
• A private Boolean data field named “on” that specifies whether the fan is on, default to off.
• A private double data field named “radius” that specifies the radius of the fan, default to 5.
• A private string data field named “color” that specifies the color of the fan, default to “blue”.
• A no-argument constructor that creates a default fan.
• Accessors and Mutators for all 4 data fields.
• A toString( ) method 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 off, the method returns the fan color and radius along with the string, “fan is off” in one combined string.
The Fan Application class
• Write a test program that creates two Fan objects. Sets all values in the mutators, and calls the toString( ) method.
• Fan Object 1 inputs:
o Assign Fastest Speed, by passing static constant FAST. Hint pass Fan.FAST to the mutator.
o Assign a radius 10
o Assign the color yellow
o Turn the fan on.
• Fan Object 2 inputs:
o Assign Medium Speed, by passing static constant MEDIUM. Hint pass Fan.MEDIUM to the mutator.
o Assign a radius 5
o Assign the color blue
o Turn the fan off.
Output:
The Fan Speed is 3, color is yellow, and radius is 10.
The Fan color is blue, radius is 5, and the fan is off.
and here is my code thus far:
public class FanTest { public static void main(String args[]) { Fan fan = new Fan(); fan.seton$off(true); fan.setcolor("blue"); fan.setspeed(3); FanTest ft = new FanTest(); System.out.println(ft.toString()); } public String toString(){ Fan fan = new Fan(); String printme = null; if(fan.on$off == true){ printme = ("Speed: " + fan.getspeed() + " Color: " + fan.color + " Radius: " + fan.radius); } if(fan.on$off == false){ printme = ("Color: " + fan.color + " Radius: " + fan.radius + " Fan is off!!"); } return(printme); } } class Fan { int speed = 1; boolean on$off = false; double radius = 5; String color = "Blue"; Fan() { this.speed = speed; this.on$off = on$off; this.radius = radius; this.color = color; } void setspeed(int s) { speed = s; } void seton$off(boolean open) { on$off = open; } void setradius(double r) { radius = r; } void setcolor(String c) { color = c; } int getspeed() { return speed; } boolean ison$off() { return on$off; } double getradius() { return radius; } String getcolor() { return color; } }
I am confused about creating 2 different objects to satisfy these instructions. help please!