ASDV-Java/Semester 2/Exams/Exam2-Practice1_CalebFontenot/Printed HTMLs/Dealership.html
2023-08-14 11:41:26 -05:00

69 lines
4.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Dealership.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}
.ST5 {color: #9876aa}
.number {color: #6897bb}
.string {color: #6a8759}
.comment {color: #808080}
.whitespace {color: #505050}
.ST3 {color: #ffc66d; font-family: monospace; font-style: italic}
.ST6 {color: #9876aa; font-family: monospace; font-style: italic}
.ST1 {color: #808080; font-family: monospace; font-weight: bold}
.ST2 {color: #8a653b}
.ST0 {color: #287bde}
.literal {color: #cc7832}
.ST4 {font-family: monospace; font-style: italic}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Exams/Exam2-Practice_CalebFontenot/src/main/java/com/calebfontenot/exam2/practice_calebfontenot/Dealership.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.exam2.practice_calebfontenot;
<span class="literal">import</span> java.util.ArrayList;
<span class="literal">import</span> java.util.Arrays;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="ST1">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> Dealership <span class="literal">extends</span> ArrayList&lt;Automobile&gt; {
<span class="comment">/**</span> <span class="comment">Sorts</span> <span class="comment">the</span> <span class="comment">inherited</span> <span class="comment">ArrayList</span> <span class="comment">of</span> <span class="comment">Automobiles</span>
<span class="comment"> * </span><span class="comment">into</span> <span class="comment">ascending</span> <span class="comment">order</span> <span class="comment">by</span> <span class="comment">vin</span> <span class="comment">number</span><span class="comment">.</span>
<span class="comment"> * </span><span class="ST1">@param</span> <span class="ST2">d</span> <span class="comment">the</span> <span class="comment">Dealership</span> <span class="comment">of</span> <span class="comment">Automobiles</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST3">sortByVin</span>(Dealership d) { <span class="comment">//java.util.Collections.sort() could do all of this in a single line</span>
Object[] dealershipArray = d.toArray();
Arrays.<span class="ST4">sort</span>(dealershipArray);
d.clear();
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i &lt; dealershipArray.<span class="ST5">length</span>; ++i) {
d.add((Automobile) dealershipArray[i]);
}
}
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST3">main</span>(String[] args)
{
Dealership d = <span class="literal">new</span> Dealership();
d.add(<span class="literal">new</span> Automobile(<span class="string">&quot;</span><span class="string">8</span><span class="string">&quot;</span>, <span class="literal">new</span> CountryOfOrigin(<span class="string">&quot;</span><span class="string">USA</span><span class="string">&quot;</span>.toCharArray())));
d.add(<span class="literal">new</span> Automobile(<span class="string">&quot;</span><span class="string">1</span><span class="string">&quot;</span>, <span class="literal">new</span> CountryOfOrigin(<span class="string">&quot;</span><span class="string">GERMANY</span><span class="string">&quot;</span>.toCharArray())));
System.<span class="ST6">out</span>.println(<span class="string">&quot;</span><span class="string">THE ORIGINAL DEALERSHIP</span><span class="literal">\n</span><span class="string">&quot;</span> + d);
Dealership.<span class="ST4">sortByVin</span>(d);
System.<span class="ST6">out</span>.println(<span class="string">&quot;</span><span class="literal">\n</span><span class="string">THE SORTED BY VIN DEALERSHIP</span><span class="literal">\n</span><span class="string">&quot;</span> + d);
}
}
</pre></body>
</html>