77 lines
4.0 KiB
HTML
77 lines
4.0 KiB
HTML
<!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}
|
|
.number {color: #6897bb}
|
|
.comment {color: #808080}
|
|
.whitespace {color: #505050}
|
|
.literal {color: #cc7832}
|
|
-->
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.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> edu.slcc.asdv.caleb.javafxballswithcomparator;
|
|
|
|
<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> width;
|
|
<span class="literal">private</span> <span class="literal">double</span> height;
|
|
|
|
<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>.width = width;
|
|
<span class="literal">this</span>.height = height;
|
|
}
|
|
|
|
<span class="comment">/**</span> <span class="comment">Return</span> <span class="comment">width</span> <span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">double</span> getWidth() {
|
|
<span class="literal">return</span> width;
|
|
}
|
|
|
|
<span class="comment">/**</span> <span class="comment">Set</span> <span class="comment">a</span> <span class="comment">new</span> <span class="comment">width</span> <span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">void</span> setWidth(<span class="literal">double</span> width) {
|
|
<span class="literal">this</span>.width = width;
|
|
}
|
|
|
|
<span class="comment">/**</span> <span class="comment">Return</span> <span class="comment">height</span> <span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">double</span> getHeight() {
|
|
<span class="literal">return</span> height;
|
|
}
|
|
|
|
<span class="comment">/**</span> <span class="comment">Set</span> <span class="comment">a</span> <span class="comment">new</span> <span class="comment">height</span> <span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">void</span> setHeight(<span class="literal">double</span> height) {
|
|
<span class="literal">this</span>.height = height;
|
|
}
|
|
|
|
@Override <span class="comment">/**</span> <span class="comment">Return</span> <span class="comment">area</span> <span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">double</span> getArea() {
|
|
<span class="literal">return</span> width * height;
|
|
}
|
|
|
|
@Override <span class="comment">/**</span> <span class="comment">Return</span> <span class="comment">perimeter</span> <span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">double</span> getPerimeter() {
|
|
<span class="literal">return</span> <span class="number">2</span> * (width + height);
|
|
}
|
|
}
|
|
|
|
|
|
</pre></body>
|
|
</html>
|