/home/caleb/ASDV-Java/Semester 2/Assignments/lab3_CalebFontenot/src/main/java/com/calebfontenot/lab3_calebfontenot/Fan.java |
package com.calebfontenot.lab3_calebfontenot;
*
* @author caleb
*/
public class Fan {
// Constants
public static final int SLOW = 1;
public static final int MEDIUM = 2;
public static final int FAST = 3;
private int speed;
private boolean isOn;
private int radius;
private String color;
public Fan() {
this.speed = 1;
this.isOn = false;
this.radius = 5;
this.color = "blue";
}
/**
* Get the value of color
*
* @return the value of color
*/
public String getColor()
{
return color;
}
/**
* Set the value of color
*
* @param color new value of color
*/
public void setColor(String color)
{
this.color = color;
}
/**
* Get the value of radius
*
* @return the value of radius
*/
public int getRadius()
{
return radius;
}
/**
* Set the value of radius
*
* @param radius new value of radius
*/
public void setRadius(int radius)
{
this.radius = radius;
}
/**
* Get the value of isOn
*
* @return the value of isOn
*/
public boolean isOn()
{
return isOn;
}
/**
* Set the value of isOn
*
* @param isOn new value of isOn
*/
public void setOn(boolean isOn)
{
this.isOn = isOn;
}
/**
* Get the value of speed
*
* @return the value of speed
*/
public int getSpeed()
{
return speed;
}
/**
* Set the value of speed
*
* @param speed new value of speed
*/
public void setSpeed(int speed)
{
this.speed = speed;
}
@Override
public String toString()
{
String returnString;
if (this.isOn) {
returnString = "fan is on. ";
}
else {
returnString = "fan is off. ";
}
returnString += "{" + "speed=" + speed + ", radius=" + radius + ", color=" + color + '}';
return returnString;
}
public static void main(String[] args)
{
Fan fan1 = new Fan();
fan1.setSpeed(Fan.FAST);
fan1.setRadius(10);
fan1.setColor("yellow");
fan1.setOn(true);
System.out.println(fan1);
Fan fan2 = new Fan();
fan2.setSpeed(Fan.MEDIUM);
fan2.setRadius(5);
fan2.setColor("blue");
fan2.setOn(false);
System.out.println(fan2.toString());
}
}