ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Circle.html
2023-04-27 12:50:36 -05:00

82 lines
4.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Circle.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; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.literal {color: #cc7832}
.ST4 {font-family: monospace; font-weight: bold; font-style: italic}
.ST0 {color: #287bde}
.string {color: #6a8759}
.number {color: #6897bb}
.ST1 {color: #9876aa}
.ST3 {color: #ffc66d}
.comment {color: #808080}
.whitespace {color: #505050}
.ST2 {color: #9876aa; font-family: monospace; font-weight: bold; font-style: italic}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Circle.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> com.calebfontenot.mp5_calebfontenot;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> Circle <span class="literal">extends</span> GeometricObject {
<span class="literal">private</span> <span class="literal">double</span> <span class="ST1">diameter</span>;
<span class="literal">public</span> Circle(<span class="literal">double</span> diameter) {
<span class="literal">this</span>.<span class="ST1">diameter</span> = diameter;
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">Circle Diameter: </span><span class="string">&quot;</span> + diameter);
}
@Override
<span class="literal">public</span> <span class="literal">double</span> <span class="ST3">getArea</span>() {
<span class="literal">double</span> radius = <span class="ST1">diameter</span> / <span class="number">2</span>;
<span class="literal">return</span> Math.<span class="ST2">PI</span> * Math.<span class="ST4">pow</span>(radius, <span class="number">2</span>);
}
@Override
<span class="literal">public</span> <span class="literal">double</span> <span class="ST3">getPerimeter</span>() {
<span class="literal">return</span> Math.<span class="ST2">PI</span> * <span class="ST1">diameter</span>;
}
@Override
<span class="literal">public</span> String <span class="ST3">toString</span>() {
<span class="literal">return</span> <span class="string">&quot;</span><span class="string">Circle{</span><span class="string">&quot;</span> + <span class="string">&quot;</span><span class="string">diameter=</span><span class="string">&quot;</span> + <span class="ST1">diameter</span> + <span class="string">&#39;</span><span class="string">}</span><span class="string">&#39;</span>;
}
@Override
<span class="literal">public</span> <span class="literal">int</span> <span class="ST3">compareTo</span>(Object t) {
System.<span class="ST2">out</span>.println(<span class="literal">this</span>.getArea() + <span class="string">&quot;</span><span class="string">, </span><span class="string">&quot;</span> + ((Circle) t).getArea());
<span class="literal">if</span> (<span class="literal">this</span>.getArea() &lt; ((Circle) t).getArea()) {
<span class="literal">return</span> -<span class="number">1</span>;
} <span class="literal">else</span> <span class="literal">if</span> (<span class="literal">this</span>.getArea() &gt; ((Circle) t).getArea()) {
<span class="literal">return</span> <span class="number">1</span>;
} <span class="literal">else</span> {
<span class="literal">return</span> <span class="number">0</span>;
}
}
<span class="comment">// The compiler made me implement this, not sure why</span>
@Override
<span class="literal">public</span> <span class="literal">int</span> <span class="ST3">compareTo</span>() {
<span class="literal">throw</span> <span class="literal">new</span> UnsupportedOperationException(<span class="string">&quot;</span><span class="string">No compare object supplied!</span><span class="string">&quot;</span>);
}
}
</pre></body>
</html>