lab3, add HTMLs
This commit is contained in:
parent
6ce8c0d880
commit
84d6edaa34
@ -0,0 +1,104 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FanList.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.comment {color: #808080}
|
||||||
|
.whitespace {color: #505050}
|
||||||
|
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||||
|
.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/FanList.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"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||||||
|
<span class="comment"> */</span>
|
||||||
|
<span class="literal">package</span> com.calebfontenot.lab3_calebfontenot;
|
||||||
|
|
||||||
|
<span class="literal">import</span> java.util.Scanner;
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">class</span> FanList {
|
||||||
|
|
||||||
|
<span class="literal">private</span> Fan[] list;
|
||||||
|
|
||||||
|
<span class="comment">// A constructor that creates a list of type fan</span>
|
||||||
|
<span class="literal">public</span> FanList(<span class="literal">int</span> listSize)
|
||||||
|
{
|
||||||
|
list = <span class="literal">new</span> Fan[listSize];
|
||||||
|
createListObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="comment">// Creates a list of Fan objects from User's input</span>
|
||||||
|
<span class="literal">private</span> <span class="literal">void</span> createListObjects()
|
||||||
|
{
|
||||||
|
Scanner scan = <span class="literal">new</span> Scanner(System.in);
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < list.length; ++i) {
|
||||||
|
Fan fan = <span class="literal">new</span> Fan();
|
||||||
|
System.out.println(<span class="string">"</span><span class="string">Enter FAN data for fan </span><span class="string">"</span> + (i + <span class="number">1</span>)
|
||||||
|
+ <span class="string">"</span><span class="string">: color, radius, speed(1, 2 or 3) and if on (t, f)</span><span class="string">"</span>);
|
||||||
|
String color = scan.next();
|
||||||
|
<span class="literal">int</span> radius = scan.nextInt();
|
||||||
|
<span class="literal">int</span> speed = scan.nextInt();
|
||||||
|
String on = scan.next();
|
||||||
|
fan.setSpeed(speed);
|
||||||
|
fan.setRadius(radius);
|
||||||
|
fan.setColor(color);
|
||||||
|
<span class="literal">if</span> (<span class="string">"</span><span class="string">t</span><span class="string">"</span>.compareToIgnoreCase(on) == <span class="number">0</span>) {
|
||||||
|
fan.setOn(<span class="literal">true</span>);
|
||||||
|
} <span class="literal">else</span> {
|
||||||
|
fan.setOn(<span class="literal">false</span>);
|
||||||
|
}
|
||||||
|
list[i] = fan;
|
||||||
|
System.out.println(<span class="string">"</span><span class="string">----------------------------------------</span><span class="string">"</span>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
<span class="literal">public</span> String toString()
|
||||||
|
{
|
||||||
|
String s = <span class="string">"</span><span class="string">FanList{</span><span class="string">"</span> + <span class="string">"</span><span class="string">list=</span><span class="literal">\n</span><span class="string">"</span>;
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < list.length; ++i) {
|
||||||
|
s += list[i].toString() + <span class="string">"</span><span class="literal">\n</span><span class="string">-----------------------</span><span class="literal">\n</span><span class="string">"</span>;
|
||||||
|
}
|
||||||
|
s += <span class="string">'</span><span class="string">}</span><span class="string">'</span>;
|
||||||
|
<span class="literal">return</span> s;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="literal">public</span> <span class="literal">void</span> sortListByRadius()
|
||||||
|
{
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < list.length - <span class="number">1</span>; ++i) {
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> j = i + <span class="number">1</span>; j < list.length; ++j) {
|
||||||
|
<span class="literal">if</span> (list[i].getRadius() > list[j].getRadius()) {
|
||||||
|
Fan temp = list[i];
|
||||||
|
list[i] = list[j];
|
||||||
|
list[j] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||||
|
{
|
||||||
|
FanList fanList = <span class="literal">new</span> FanList(<span class="number">3</span>);
|
||||||
|
System.out.println(fanList);
|
||||||
|
fanList.sortListByRadius();
|
||||||
|
System.out.println(fanList.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
@ -0,0 +1,144 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Stock.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}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.comment {color: #808080}
|
||||||
|
.whitespace {color: #505050}
|
||||||
|
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||||
|
.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/Stock.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"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||||||
|
<span class="comment"> */</span>
|
||||||
|
<span class="literal">package</span> com.calebfontenot.lab3_calebfontenot;
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">class</span> Stock {
|
||||||
|
|
||||||
|
<span class="literal">private</span> String symbol;
|
||||||
|
<span class="literal">private</span> String name;
|
||||||
|
<span class="literal">private</span> <span class="literal">double</span> previousClosingPrice;
|
||||||
|
<span class="literal">private</span> <span class="literal">double</span> currentPrice;
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> * </span><span class="comment">Get</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">currentPrice</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@return</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">currentPrice</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">double</span> getCurrentPrice()
|
||||||
|
{
|
||||||
|
<span class="literal">return</span> currentPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> * </span><span class="comment">Set</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">currentPrice</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@param</span> <span class="comment">currentPrice</span> <span class="comment">new</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">currentPrice</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">void</span> setCurrentPrice(<span class="literal">double</span> currentPrice)
|
||||||
|
{
|
||||||
|
<span class="literal">this</span>.currentPrice = currentPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> * </span><span class="comment">Get</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">previousClosingPrice</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@return</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">previousClosingPrice</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">double</span> getPreviousClosingPrice()
|
||||||
|
{
|
||||||
|
<span class="literal">return</span> previousClosingPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> * </span><span class="comment">Set</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">previousClosingPrice</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@param</span> <span class="comment">previousClosingPrice</span> <span class="comment">new</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">previousClosingPrice</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">void</span> setPreviousClosingPrice(<span class="literal">double</span> previousClosingPrice)
|
||||||
|
{
|
||||||
|
<span class="literal">this</span>.previousClosingPrice = previousClosingPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> * </span><span class="comment">Get</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">name</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@return</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">name</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> String getName()
|
||||||
|
{
|
||||||
|
<span class="literal">return</span> name;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> * </span><span class="comment">Set</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">name</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@param</span> <span class="comment">name</span> <span class="comment">new</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">name</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">void</span> setName(String name)
|
||||||
|
{
|
||||||
|
<span class="literal">this</span>.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> * </span><span class="comment">Get</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">symbol</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@return</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">symbol</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> String getSymbol()
|
||||||
|
{
|
||||||
|
<span class="literal">return</span> symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> * </span><span class="comment">Set</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">symbol</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@param</span> <span class="comment">symbol</span> <span class="comment">new</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">symbol</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">void</span> setSymbol(String symbol)
|
||||||
|
{
|
||||||
|
<span class="literal">this</span>.symbol = symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="literal">public</span> <span class="literal">double</span> getChangePercent() {
|
||||||
|
<span class="literal">return</span> <span class="literal">this</span>.currentPrice - <span class="literal">this</span>.previousClosingPrice;
|
||||||
|
<span class="comment">//(((this.previousClosingPrice - this.currentPrice) / Math.abs(this.previousClosingPrice)) * 100)</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
<span class="literal">public</span> String toString()
|
||||||
|
{
|
||||||
|
<span class="literal">return</span> <span class="string">"</span><span class="string">Stock{</span><span class="string">"</span> + <span class="string">"</span><span class="string">symbol=</span><span class="string">"</span> + symbol + <span class="string">"</span><span class="string">, name=</span><span class="string">"</span> + name + <span class="string">"</span><span class="string">, previousClosingPrice=</span><span class="string">"</span> + previousClosingPrice + <span class="string">"</span><span class="string">, currentPrice=</span><span class="string">"</span> + currentPrice + <span class="string">"</span><span class="string">}</span><span class="string">"</span>+ <span class="string">"</span><span class="literal">\n</span><span class="string">"</span> + <span class="string">"</span><span class="string">Change in Percent: </span><span class="string">"</span> + <span class="literal">this</span>.getChangePercent();
|
||||||
|
}
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||||
|
{
|
||||||
|
Stock stock1 = <span class="literal">new</span> Stock();
|
||||||
|
stock1.setSymbol(<span class="string">"</span><span class="string">ORCL</span><span class="string">"</span>);
|
||||||
|
stock1.setName(<span class="string">"</span><span class="string">Oracle Corporation</span><span class="string">"</span>);
|
||||||
|
stock1.setPreviousClosingPrice(<span class="number">34.5</span>);
|
||||||
|
stock1.setCurrentPrice(<span class="number">34.35</span>);
|
||||||
|
System.out.println(stock1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
@ -0,0 +1,100 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>StockList.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.comment {color: #808080}
|
||||||
|
.whitespace {color: #505050}
|
||||||
|
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||||
|
.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/StockList.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"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||||||
|
<span class="comment"> */</span>
|
||||||
|
<span class="literal">package</span> com.calebfontenot.lab3_calebfontenot;
|
||||||
|
|
||||||
|
<span class="literal">import</span> java.util.Scanner;
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">class</span> StockList {
|
||||||
|
|
||||||
|
<span class="literal">private</span> Stock[] list;
|
||||||
|
|
||||||
|
<span class="comment">// A constructor that creates a list of type stock</span>
|
||||||
|
<span class="literal">public</span> StockList(<span class="literal">int</span> listSize)
|
||||||
|
{
|
||||||
|
list = <span class="literal">new</span> Stock[listSize];
|
||||||
|
createListObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="comment">// Creates a list of Fan objects from User's input</span>
|
||||||
|
<span class="literal">private</span> <span class="literal">void</span> createListObjects()
|
||||||
|
{
|
||||||
|
Scanner scan = <span class="literal">new</span> Scanner(System.in);
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < list.length; ++i) {
|
||||||
|
Stock stock = <span class="literal">new</span> Stock();
|
||||||
|
System.out.println(<span class="string">"</span><span class="string">Enter Stock data for stock </span><span class="string">"</span> + (i + <span class="number">1</span>)
|
||||||
|
+ <span class="string">"</span><span class="string">: symbol, name, previous closing price, and current price</span><span class="string">"</span>);
|
||||||
|
String symbol = scan.next();
|
||||||
|
String name = scan.next();
|
||||||
|
<span class="literal">double</span> previousClosingPrice = scan.nextDouble();
|
||||||
|
<span class="literal">double</span> currentPrice = scan.nextDouble();
|
||||||
|
stock.setSymbol(symbol);
|
||||||
|
stock.setName(name);
|
||||||
|
stock.setPreviousClosingPrice(previousClosingPrice);
|
||||||
|
stock.setCurrentPrice(currentPrice);
|
||||||
|
list[i] = stock;
|
||||||
|
System.out.println(<span class="string">"</span><span class="string">----------------------------------------</span><span class="string">"</span>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
<span class="literal">public</span> String toString()
|
||||||
|
{
|
||||||
|
String s = <span class="string">"</span><span class="string">StockList{</span><span class="string">"</span> + <span class="string">"</span><span class="string">list=</span><span class="literal">\n</span><span class="string">"</span>;
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < list.length; ++i) {
|
||||||
|
s += list[i].toString() + <span class="string">"</span><span class="literal">\n</span><span class="string">-----------------------</span><span class="literal">\n</span><span class="string">"</span>;
|
||||||
|
}
|
||||||
|
s += <span class="string">'</span><span class="string">}</span><span class="string">'</span>;
|
||||||
|
<span class="literal">return</span> s;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="literal">public</span> <span class="literal">void</span> sortByChangeInPercentage()
|
||||||
|
{
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < list.length - <span class="number">1</span>; ++i) {
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> j = i + <span class="number">1</span>; j < list.length; ++j) {
|
||||||
|
<span class="literal">if</span> (list[i].getChangePercent() > list[j].getChangePercent()) {
|
||||||
|
Stock temp = list[i];
|
||||||
|
list[i] = list[j];
|
||||||
|
list[j] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||||
|
{
|
||||||
|
StockList stockList = <span class="literal">new</span> StockList(<span class="number">3</span>);
|
||||||
|
System.out.println(stockList);
|
||||||
|
stockList.sortByChangeInPercentage();
|
||||||
|
System.out.println(stockList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
160
Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/fan.html
Normal file
160
Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/fan.html
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
<!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>
|
Loading…
Reference in New Issue
Block a user