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

123 lines
7.9 KiB
HTML
Raw 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>GeometricObject.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}
.string {color: #6a8759}
.ST1 {color: #9876aa}
.ST2 {color: #ffc66d}
.comment {color: #808080}
.whitespace {color: #505050}
.ST3 {color: #ffc66d; 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/GeometricObject.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">abstract</span> <span class="literal">class</span> GeometricObject <span class="literal">implements</span> Comparable {
<span class="literal">private</span> String <span class="ST1">color</span> = <span class="string">&quot;</span><span class="string">white</span><span class="string">&quot;</span>;
<span class="literal">private</span> <span class="literal">boolean</span> <span class="ST1">filled</span>;
<span class="literal">private</span> java.util.Date <span class="ST1">dateCreated</span>;
<span class="comment">/**</span>
<span class="comment"> * </span><span class="comment">Construct</span> <span class="comment">a</span> <span class="comment">default</span> <span class="comment">geometric</span> <span class="comment">object</span>
<span class="comment">*/</span>
<span class="literal">protected</span> GeometricObject() {
<span class="ST1">dateCreated</span> = <span class="literal">new</span> java.util.Date();
}
<span class="comment">/**</span>
<span class="comment"> * </span><span class="comment">Construct</span> <span class="comment">a</span> <span class="comment">geometric</span> <span class="comment">object</span> <span class="comment">with</span> <span class="comment">color</span> <span class="comment">and</span> <span class="comment">filled</span> <span class="comment">value</span>
<span class="comment">*/</span>
<span class="literal">protected</span> GeometricObject(String color, <span class="literal">boolean</span> filled) {
<span class="ST1">dateCreated</span> = <span class="literal">new</span> java.util.Date();
<span class="literal">this</span>.<span class="ST1">color</span> = color;
<span class="literal">this</span>.<span class="ST1">filled</span> = filled;
}
<span class="comment">/**</span>
<span class="comment"> * </span><span class="comment">Return</span> <span class="comment">color</span>
<span class="comment">*/</span>
<span class="literal">public</span> String <span class="ST2">getColor</span>() {
<span class="literal">return</span> <span class="ST1">color</span>;
}
<span class="comment">/**</span>
<span class="comment"> * </span><span class="comment">Set</span> <span class="comment">a</span> <span class="comment">new</span> <span class="comment">color</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">void</span> <span class="ST2">setColor</span>(String color) {
<span class="literal">this</span>.<span class="ST1">color</span> = color;
}
<span class="comment">/**</span>
<span class="comment"> * </span><span class="comment">Return</span> <span class="comment">filled</span><span class="comment">.</span> <span class="comment">Since</span> <span class="comment">filled</span> <span class="comment">is</span> <span class="comment">boolean</span><span class="comment">, </span><span class="comment">the</span> <span class="comment">get</span> <span class="comment">method</span> <span class="comment">is</span> <span class="comment">named</span> <span class="comment">isFilled</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST2">isFilled</span>() {
<span class="literal">return</span> <span class="ST1">filled</span>;
}
<span class="comment">/**</span>
<span class="comment"> * </span><span class="comment">Set</span> <span class="comment">a</span> <span class="comment">new</span> <span class="comment">filled</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">void</span> <span class="ST2">setFilled</span>(<span class="literal">boolean</span> filled) {
<span class="literal">this</span>.<span class="ST1">filled</span> = filled;
}
<span class="comment">/**</span>
<span class="comment"> * </span><span class="comment">Get</span> <span class="comment">dateCreated</span>
<span class="comment">*/</span>
<span class="literal">public</span> java.util.Date <span class="ST2">getDateCreated</span>() {
<span class="literal">return</span> <span class="ST1">dateCreated</span>;
}
@Override
<span class="literal">public</span> String <span class="ST2">toString</span>() {
<span class="literal">return</span> <span class="string">&quot;</span><span class="string">created on </span><span class="string">&quot;</span> + <span class="ST1">dateCreated</span> + <span class="string">&quot;</span><span class="literal">\n</span><span class="string">color: </span><span class="string">&quot;</span> + <span class="ST1">color</span>
+ <span class="string">&quot;</span><span class="string"> and filled: </span><span class="string">&quot;</span> + <span class="ST1">filled</span>;
}
<span class="comment">/**</span>
<span class="comment"> * </span><span class="comment">Abstract</span> <span class="comment">method</span> <span class="comment">getArea</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">abstract</span> <span class="literal">double</span> <span class="ST2">getArea</span>();
<span class="comment">/**</span>
<span class="comment"> * </span><span class="comment">Abstract</span> <span class="comment">method</span> <span class="comment">getPerimeter</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">abstract</span> <span class="literal">double</span> <span class="ST2">getPerimeter</span>();
<span class="comment">// Additional code below</span>
<span class="literal">public</span> <span class="literal">abstract</span> <span class="literal">int</span> <span class="ST2">compareTo</span>(GeometricObject t);
<span class="literal">public</span> <span class="literal">static</span> GeometricObject <span class="ST3">max</span>(GeometricObject o1, GeometricObject o2) {
<span class="literal">if</span> (o1.getArea() &gt;= o2.getArea()) {
<span class="literal">return</span> o1;
} <span class="literal">else</span> {
<span class="literal">return</span> o2;
}
}
}
</pre></body>
</html>