161 lines
3.6 KiB
HTML
161 lines
3.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>Fan.java</title>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<style type="text/css">
|
|
<!--
|
|
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
|
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
|
table {color: #888888; background-color: #313335; font-family: monospace}
|
|
.comment {color: #808080}
|
|
.whitespace {color: #505050}
|
|
.literal {color: #cc7832}
|
|
-->
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/lab3_CalebFontenot/src/main/java/com/calebfontenot/lab3_calebfontenot/Fan.java</td></tr></table>
|
|
<pre>
|
|
<span class="comment">/*</span>
|
|
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
|
<span class="comment"> */</span>
|
|
<span class="literal">package</span> com.calebfontenot.lab3_calebfontenot;
|
|
|
|
<span class="comment">/**</span>
|
|
*
|
|
* @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());
|
|
}
|
|
}
|
|
|
|
</pre></body>
|
|
</html>
|