Write your toString method like this
public String toString() {
String description = "";
if (fanOn = true) {
description += "The speed of the fan is " + speed
+ ", the color of the the fan is " + color
+ ", and the radius of the fan is " + radius + ".";
} else {
description += "The fan is off but the color is " + color
+ " and the radius is " + radius + ".";
}
return description;
}
I am not sure what you want to do with slow/medium/fast(seems a redundancy with speed). But if you want to modify it, don't declare it as final.
private int slow = 1;
private int medium = 2;
private int fast = 3;
You need a constructor for your test program. (by the way, you should name your class Fan)
public fan(int speed, double radius, String color, boolean fanOn ) {
this.speed = speed;
this.radius = radius;
this.color = color;
this.fanOn = fanOn;
}
Your test program should look like this.
public static void main(String args[]) {
fan fan1 = new fan(100, 100, "red", true);
fan fan2 = new fan(200, 200, "green", false);
}