ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Rectangle.html

96 lines
5.2 KiB
HTML
Raw Permalink Normal View History

2023-04-27 12:50:36 -05:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Rectangle.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}
.ST0 {color: #287bde}
.number {color: #6897bb}
.string {color: #6a8759}
.ST1 {color: #9876aa}
.ST2 {color: #ffc66d}
.comment {color: #808080}
.whitespace {color: #505050}
.ST3 {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/Rectangle.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> Rectangle <span class="literal">extends</span> GeometricObject{
<span class="literal">private</span> <span class="literal">double</span> <span class="ST1">width</span>;
<span class="literal">private</span> <span class="literal">double</span> <span class="ST1">height</span>;
<span class="literal">public</span> Rectangle() {
}
<span class="literal">public</span> Rectangle(<span class="literal">double</span> width, <span class="literal">double</span> height) {
<span class="literal">this</span>.<span class="ST1">width</span> = width;
<span class="literal">this</span>.<span class="ST1">height</span> = height;
}
<span class="literal">public</span> <span class="literal">double</span> <span class="ST2">getWidth</span>() {
<span class="literal">return</span> <span class="ST1">width</span>;
}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST2">setWidth</span>(<span class="literal">double</span> width) {
<span class="literal">this</span>.<span class="ST1">width</span> = width;
}
<span class="literal">public</span> <span class="literal">double</span> <span class="ST2">getHeight</span>() {
<span class="literal">return</span> <span class="ST1">height</span>;
}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST2">setHeight</span>(<span class="literal">double</span> height) {
<span class="literal">this</span>.<span class="ST1">height</span> = height;
}
@Override
<span class="literal">public</span> <span class="literal">double</span> <span class="ST2">getArea</span>() {
<span class="literal">return</span> <span class="ST1">width</span> * <span class="ST1">height</span>;
}
@Override
<span class="literal">public</span> <span class="literal">double</span> <span class="ST2">getPerimeter</span>() {
<span class="literal">return</span> <span class="number">2</span> * (<span class="ST1">width</span> + <span class="ST1">height</span>);
}
@Override
<span class="literal">public</span> <span class="literal">int</span> <span class="ST2">compareTo</span>(GeometricObject t) {
System.<span class="ST3">out</span>.println(<span class="literal">this</span>.getArea() + <span class="string">&quot;</span><span class="string">, </span><span class="string">&quot;</span> + (t).getArea());
<span class="literal">if</span> (<span class="literal">this</span>.getArea() &lt; (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; (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>;
}
}
@Override
<span class="literal">public</span> <span class="literal">int</span> <span class="ST2">compareTo</span>(Object t) {
<span class="literal">throw</span> <span class="literal">new</span> UnsupportedOperationException(<span class="string">&quot;</span><span class="string">Not supported yet.</span><span class="string">&quot;</span>); <span class="comment">// Generated from </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody</span>
}
}
</pre></body>
</html>