Semester 3 😎
This commit is contained in:
parent
02a88ea7fe
commit
8b9b520393
7
.gitignore
vendored
7
.gitignore
vendored
@ -123,5 +123,12 @@
|
||||
/Semester 2/Assignments/JavaFX_CalebFontenot/target/
|
||||
/Semester 2/Assignments/JavaFX_CalebFontenot/nbproject/private/
|
||||
/Semester 2/Assignments/JavaFX_CalebFontenot/build/
|
||||
<<<<<<< Updated upstream
|
||||
/Semester 2/Exams/ProgrammingExam2_CalebFontenot/nbproject/private/
|
||||
/Semester 2/Exams/ProgrammingExam2_CalebFontenot/build/
|
||||
=======
|
||||
>>>>>>> Stashed changes
|
||||
/Semester 2/Assignments/bruh/nbproject/private/
|
||||
/Semester 2/Exams/Exam2-Practice_CalebFontenot/target/
|
||||
/Semester 2/Exams/Exam2-Practice1_CalebFontenot/target/
|
||||
/Semester 2/Assignments/Exam2-Practice2_CalebFontenot/target/
|
||||
|
@ -0,0 +1,60 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>BidirectionalBindingDemo.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}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/JavaFX_CalebFontenot/src/javafx_calebfontenot/BidirectionalBindingDemo.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> javafx_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> javafx.beans.property.DoubleProperty;
|
||||
<span class="literal">import</span> javafx.beans.property.SimpleDoubleProperty;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> BidirectionalBindingDemo {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
DoubleProperty d1 = <span class="literal">new</span> SimpleDoubleProperty(<span class="number">1</span>);
|
||||
DoubleProperty d2 = <span class="literal">new</span> SimpleDoubleProperty(<span class="number">2</span>);
|
||||
|
||||
System.out.println(<span class="string">"</span><span class="string">d1 is </span><span class="string">"</span> + d1.getValue()
|
||||
+ <span class="string">"</span><span class="string"> and d2 is </span><span class="string">"</span> + d2.getValue());
|
||||
d1.bindBidirectional(d2);
|
||||
System.out.println(<span class="string">"</span><span class="string">d1 is </span><span class="string">"</span> + d1.getValue()
|
||||
+ <span class="string">"</span><span class="string"> and d2 is </span><span class="string">"</span> + d2.getValue());
|
||||
d1.setValue(<span class="number">50.1</span>);
|
||||
System.out.println(<span class="string">"</span><span class="string">d1 is </span><span class="string">"</span> + d1.getValue()
|
||||
+ <span class="string">"</span><span class="string"> and d2 is </span><span class="string">"</span> + d2.getValue());
|
||||
d2.setValue(<span class="number">70.2</span>);
|
||||
System.out.println(<span class="string">"</span><span class="string">d1 is </span><span class="string">"</span> + d1.getValue()
|
||||
+ <span class="string">"</span><span class="string"> and d2 is </span><span class="string">"</span> + d2.getValue());
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>BindingDemo.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}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST2 {color: #ffc66d; font-family: monospace; font-style: italic}
|
||||
.ST3 {color: #9876aa; font-family: monospace; font-style: italic}
|
||||
.ST1 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.ST0 {color: #287bde}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/JavaFX_CalebFontenot/src/javafx_calebfontenot/BindingDemo.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> javafx_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> javafx.beans.property.DoubleProperty;
|
||||
<span class="literal">import</span> javafx.beans.property.SimpleDoubleProperty;
|
||||
|
||||
<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> BindingDemo {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST2">main</span>(String[] args)
|
||||
{
|
||||
DoubleProperty d1 = <span class="literal">new</span> SimpleDoubleProperty(<span class="number">1</span>);
|
||||
DoubleProperty d2 = <span class="literal">new</span> SimpleDoubleProperty(<span class="number">1</span>);
|
||||
|
||||
d1.bind(d2);
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">d1 is </span><span class="string">"</span> + d1.getValue()
|
||||
+ <span class="string">"</span><span class="string"> and d2 is </span><span class="string">"</span> + d2.getValue());
|
||||
d2.setValue(<span class="number">7</span><span class="number">0.2</span>);
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">d1 is </span><span class="string">"</span> + d1.getValue()
|
||||
+ <span class="string">"</span><span class="string"> and d2 is</span><span class="string">"</span> + d2.getValue());
|
||||
<span class="comment">//d1.set(33); // remove comment to crash the program.</span>
|
||||
<span class="comment">// When you bind, you cannot change. It is like getting married.</span>
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -0,0 +1,87 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Checkerboard.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}
|
||||
.ST2 {color: #ffc66d}
|
||||
.number {color: #6897bb}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST3 {color: #9876aa; font-family: monospace; font-style: italic}
|
||||
.ST4 {color: #ffc66d; font-family: monospace; font-style: italic}
|
||||
.ST1 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.ST0 {color: #287bde}
|
||||
.literal {color: #cc7832}
|
||||
.ST5 {font-family: monospace; font-style: italic}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/JavaFX_CalebFontenot/src/javafx_calebfontenot/Checkerboard.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> javafx_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> javafx.application.Application;
|
||||
<span class="literal">import</span> <span class="literal">static</span> javafx.application.Application.launch;
|
||||
<span class="literal">import</span> javafx.scene.Scene;
|
||||
<span class="literal">import</span> javafx.scene.layout.Pane;
|
||||
<span class="literal">import</span> javafx.scene.paint.Color;
|
||||
<span class="literal">import</span> javafx.scene.shape.Rectangle;
|
||||
<span class="literal">import</span> javafx.stage.Stage;
|
||||
|
||||
<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> Checkerboard <span class="literal">extends</span> Application {
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST2">start</span>(Stage primaryStage) <span class="literal">throws</span> Exception
|
||||
{
|
||||
Pane pane = <span class="literal">new</span> Pane(); <span class="comment">// Create a pane object</span>
|
||||
Scene scene = <span class="literal">new</span> Scene(pane, <span class="number">8</span><span class="number">00</span>, <span class="number">8</span><span class="number">00</span>); <span class="comment">// Create a scene object</span>
|
||||
primaryStage.setScene(scene); <span class="comment">// Set the stage scene to the scene object</span>
|
||||
primaryStage.show(); <span class="comment">// Make the window display on the screen</span>
|
||||
Rectangle[][] r = <span class="literal">new</span> Rectangle[<span class="number">8</span>][<span class="number">8</span>];
|
||||
<span class="comment">//Fill array with rectangle objects.</span>
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="number">8</span>; ++i) {
|
||||
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < <span class="number">8</span>; ++j) {
|
||||
r[i][j] = <span class="literal">new</span> Rectangle();
|
||||
}
|
||||
}
|
||||
<span class="literal">int</span> j = <span class="number">0</span>;
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="number">8</span>; ++i) {
|
||||
<span class="literal">for</span> (j = <span class="number">0</span>; j < <span class="number">8</span>; ++j) {
|
||||
r[i][j].setWidth(<span class="number">8</span><span class="number">0</span>);
|
||||
r[i][j].setHeight(<span class="number">8</span><span class="number">0</span>);
|
||||
<span class="literal">if</span> (j > <span class="number">0</span>) {
|
||||
r[i][j].setX(r[i][j - <span class="number">1</span>].getX() + <span class="number">75</span>);
|
||||
}
|
||||
<span class="literal">if</span> ((i + j) % <span class="number">2</span> == <span class="number">0</span>) {
|
||||
r[i][j].setFill(Color.<span class="ST3">RED</span>);
|
||||
} <span class="literal">else</span> {
|
||||
r[i][j].setFill(Color.<span class="ST3">BLACK</span>);
|
||||
}
|
||||
r[i][j].setY((i + <span class="number">1</span>) * <span class="number">75</span>);
|
||||
pane.getChildren().add(r[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST4">main</span>(String[] args)
|
||||
{
|
||||
<span class="ST5">launch</span>(args);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -8,17 +8,12 @@
|
||||
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}
|
||||
.ST0 {color: #ffc66d}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.whitespace {color: #505050}
|
||||
.ST1 {color: #9876aa; font-family: monospace; font-style: italic}
|
||||
.comment {color: #808080}
|
||||
.ST4 {color: #ffc66d; font-family: monospace; font-style: italic}
|
||||
.ST2 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.ST3 {color: #8a653b}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #cc7832}
|
||||
.ST5 {font-family: monospace; font-style: italic}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
@ -37,16 +32,16 @@ table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
<span class="literal">public</span> <span class="literal">class</span> JavaFX_CalebFontenot <span class="literal">extends</span> Application {
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST0">start</span>(Stage primaryStage)
|
||||
<span class="literal">public</span> <span class="literal">void</span> start(Stage primaryStage)
|
||||
{
|
||||
Button btn = <span class="literal">new</span> Button();
|
||||
btn.setText(<span class="string">"</span><span class="string">Say 'Hello World'</span><span class="string">"</span>);
|
||||
btn.setOnAction(<span class="literal">new</span> EventHandler<ActionEvent>() {
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST0">handle</span>(ActionEvent event)
|
||||
<span class="literal">public</span> <span class="literal">void</span> handle(ActionEvent event)
|
||||
{
|
||||
System.<span class="ST1">out</span>.println(<span class="string">"</span><span class="string">Hello World!</span><span class="string">"</span>);
|
||||
System.out.println(<span class="string">"</span><span class="string">Hello World!</span><span class="string">"</span>);
|
||||
}
|
||||
});
|
||||
|
||||
@ -54,7 +49,7 @@ table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
StackPane root = <span class="literal">new</span> StackPane();
|
||||
root.getChildren().add(btn);
|
||||
|
||||
Scene scene = <span class="literal">new</span> Scene(root, <span class="number">3</span><span class="number">00</span>, <span class="number">2</span><span class="number">50</span>);
|
||||
Scene scene = <span class="literal">new</span> Scene(root, <span class="number">300</span>, <span class="number">250</span>);
|
||||
|
||||
primaryStage.setTitle(<span class="string">"</span><span class="string">Hello World!</span><span class="string">"</span>);
|
||||
primaryStage.setScene(scene);
|
||||
@ -62,11 +57,11 @@ table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="ST2">@param</span> <span class="ST3">args</span> <span class="comment">the</span> <span class="comment">command</span> <span class="comment">line</span> <span class="comment">arguments</span>
|
||||
<span class="comment"> * </span><span class="ST0">@param</span> <span class="comment">args</span> <span class="comment">the</span> <span class="comment">command</span> <span class="comment">line</span> <span class="comment">arguments</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST4">main</span>(String[] args)
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
<span class="ST5">launch</span>(args);
|
||||
launch(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,17 +8,12 @@
|
||||
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}
|
||||
.ST2 {color: #ffc66d}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST3 {color: #9876aa; font-family: monospace; font-style: italic}
|
||||
.ST4 {color: #ffc66d; font-family: monospace; font-style: italic}
|
||||
.ST1 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.ST0 {color: #287bde}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #cc7832}
|
||||
.ST5 {font-family: monospace; font-style: italic}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
@ -26,8 +21,8 @@ table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/JavaFX_CalebFontenot/src/javafx_calebfontenot/ShowCircleCentered.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"> * 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> javafx_calebfontenot;
|
||||
|
||||
@ -40,12 +35,12 @@ table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
|
||||
<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="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> ShowCircleCentered <span class="literal">extends</span> Application {
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST2">start</span>(Stage primaryStage)
|
||||
<span class="literal">public</span> <span class="literal">void</span> start(Stage primaryStage)
|
||||
{
|
||||
<span class="comment">// Create a pane to hold the Circle</span>
|
||||
Pane pane = <span class="literal">new</span> Pane();
|
||||
@ -54,20 +49,20 @@ table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
Circle circle = <span class="literal">new</span> Circle();
|
||||
circle.centerXProperty().bind(pane.widthProperty().divide(<span class="number">2</span>));
|
||||
circle.centerYProperty().bind(pane.heightProperty().divide(<span class="number">2</span>));
|
||||
circle.setRadius(<span class="number">5</span><span class="number">0</span>);
|
||||
circle.setStroke(Color.<span class="ST3">BLACK</span>);
|
||||
circle.setFill(Color.<span class="ST3">WHITE</span>);
|
||||
circle.setRadius(<span class="number">50</span>);
|
||||
circle.setStroke(Color.BLACK);
|
||||
circle.setFill(Color.WHITE);
|
||||
pane.getChildren().add(circle); <span class="comment">// Add the circle to the pane</span>
|
||||
|
||||
<span class="comment">// Create a scene and place it in the stage</span>
|
||||
Scene scene = <span class="literal">new</span> Scene(pane, <span class="number">2</span><span class="number">00</span>, <span class="number">2</span><span class="number">00</span>);
|
||||
Scene scene = <span class="literal">new</span> Scene(pane, <span class="number">200</span>, <span class="number">200</span>);
|
||||
primaryStage.setTitle(<span class="string">"</span><span class="string">ShowCircleCentered</span><span class="string">"</span>); <span class="comment">// Set the stage title</span>
|
||||
primaryStage.setScene(scene); <span class="comment">// Place the scene in the stage</span>
|
||||
primaryStage.show(); <span class="comment">// Display the stage</span>
|
||||
}
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST4">main</span>(String[] args)
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
<span class="ST5">launch</span>(args);
|
||||
launch(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
Scene scene = <span class="literal">new</span> Scene(pane, <span class="number">3</span><span class="number">00</span>, <span class="number">2</span><span class="number">00</span>); <span class="comment">// Create a scene object</span>
|
||||
primaryStage.setScene(scene); <span class="comment">// Set the stage scene to the scene object</span>
|
||||
primaryStage.show(); <span class="comment">// Make the window display on the screen</span>
|
||||
Rectangle r = <span class="literal">new</span> Rectangle(<span class="number">3</span><span class="number">0</span>, <span class="number">3</span><span class="number">0</span>, <span class="number">8</span><span class="number">8</span>, <span class="number">4</span><span class="number">4</span>);
|
||||
Rectangle r = <span class="literal">new</span> Rectangle(<span class="number">3</span><span class="number">0</span>, <span class="number">3</span><span class="number">0</span>, <span class="number">8</span><span class="number">8</span>, <span class="number">4</span><span class="number">4</span>); <span class="comment">// Crate a rectangle object with these dimentions.</span>
|
||||
r.setX(<span class="number">3</span><span class="number">0</span>);
|
||||
r.setY(<span class="number">3</span><span class="number">0</span>);
|
||||
r.setStroke(Color.<span class="ST3">BLUE</span>); <span class="comment">// Set the rectangle outline to Blue</span>
|
||||
|
Binary file not shown.
@ -0,0 +1,4 @@
|
||||
libs.CopyLibs.classpath=\
|
||||
${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
|
||||
libs.CopyLibs.displayName=CopyLibs Task
|
||||
libs.CopyLibs.prop-version=3.0
|
@ -43,14 +43,39 @@ is divided into following sections:
|
||||
<property file="nbproject/private/configs/${config}.properties"/>
|
||||
<property file="nbproject/private/private.properties"/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private" name="-init-user">
|
||||
<target name="-pre-init-libraries">
|
||||
<property location="./lib/nblibraries.properties" name="libraries.path"/>
|
||||
<dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
|
||||
<pathconvert dirsep="/" property="libraries.dir">
|
||||
<path path="${libraries.dir.nativedirsep}"/>
|
||||
</pathconvert>
|
||||
<basename file="${libraries.path}" property="libraries.basename" suffix=".properties"/>
|
||||
<available file="${libraries.dir}/${libraries.basename}-private.properties" property="private.properties.available"/>
|
||||
</target>
|
||||
<target depends="-pre-init-libraries" if="private.properties.available" name="-init-private-libraries">
|
||||
<loadproperties encoding="ISO-8859-1" srcfile="${libraries.dir}/${libraries.basename}-private.properties">
|
||||
<filterchain>
|
||||
<replacestring from="$${base}" to="${libraries.dir}"/>
|
||||
<escapeunicode/>
|
||||
</filterchain>
|
||||
</loadproperties>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-private-libraries" name="-init-libraries">
|
||||
<loadproperties encoding="ISO-8859-1" srcfile="${libraries.path}">
|
||||
<filterchain>
|
||||
<replacestring from="$${base}" to="${libraries.dir}"/>
|
||||
<escapeunicode/>
|
||||
</filterchain>
|
||||
</loadproperties>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-libraries" name="-init-user">
|
||||
<property file="${user.properties.file}"/>
|
||||
<!-- The two properties below are usually overridden -->
|
||||
<!-- by the active platform. Just a fallback. -->
|
||||
<property name="default.javac.source" value="1.8"/>
|
||||
<property name="default.javac.target" value="1.8"/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-user" name="-init-project">
|
||||
<target depends="-pre-init,-init-private,-init-libraries,-init-user" name="-init-project">
|
||||
<property file="nbproject/configs/${config}.properties"/>
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
@ -119,7 +144,7 @@ is divided into following sections:
|
||||
<property name="dist.jlink.output" value="${dist.jlink.dir}/${application.title}"/>
|
||||
<property name="module.name" value=""/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property,-init-modules-supported" name="-do-init">
|
||||
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property,-init-modules-supported" name="-do-init">
|
||||
<j2seproject1:property name="platform.home" value="platforms.${platform.active}.home"/>
|
||||
<j2seproject1:property name="platform.bootcp" value="platforms.${platform.active}.bootclasspath"/>
|
||||
<j2seproject1:property name="platform.compiler" value="platforms.${platform.active}.compile"/>
|
||||
@ -310,7 +335,7 @@ is divided into following sections:
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
|
||||
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init" name="-init-check">
|
||||
<fail unless="src.dir">Must set src.dir</fail>
|
||||
<fail unless="test.src.dir">Must set test.src.dir</fail>
|
||||
<fail unless="build.dir">Must set build.dir</fail>
|
||||
@ -1072,7 +1097,7 @@ is divided into following sections:
|
||||
<target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
|
||||
<property name="ap.cmd.line.internal" value=""/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
|
||||
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
|
@ -3,6 +3,6 @@ build.xml.script.CRC32=94f41b4f
|
||||
build.xml.stylesheet.CRC32=f85dc8f2@1.105.0.48
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=ebd628e2
|
||||
nbproject/build-impl.xml.script.CRC32=58460c11
|
||||
nbproject/build-impl.xml.data.CRC32=9652703a
|
||||
nbproject/build-impl.xml.script.CRC32=ee125f98
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.105.0.48
|
||||
|
@ -1,6 +1,5 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.processor.options=
|
||||
annotation.processing.processors.list=
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
@ -42,8 +41,10 @@ javac.classpath=
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.external.vm=false
|
||||
javac.modulepath=
|
||||
javac.processormodulepath=
|
||||
javac.processormodulepath=\
|
||||
null
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.8
|
||||
@ -58,6 +59,7 @@ javac.test.processorpath=\
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.html5=false
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
@ -68,11 +70,16 @@ javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
javafx.application.implementation.version=1.0
|
||||
javafx.binarycss=false
|
||||
javafx.deploy.adddesktopshortcut=false
|
||||
javafx.deploy.addstartmenushortcut=false
|
||||
javafx.deploy.allowoffline=true
|
||||
# If true, application update mode is set to 'background', if false, update mode is set to 'eager'
|
||||
javafx.deploy.backgroundupdate=false
|
||||
javafx.deploy.disable.proxy=false
|
||||
javafx.deploy.embedJNLP=true
|
||||
javafx.deploy.includeDT=true
|
||||
javafx.deploy.installpermanently=false
|
||||
javafx.deploy.permissionselevated=false
|
||||
# Set true to prevent creation of temporary copy of deployment artifacts before each run (disables concurrent runs)
|
||||
javafx.disable.concurrent.runs=false
|
||||
# Set true to enable multiple concurrent runs of the same WebStart or Run-in-Browser project
|
||||
@ -93,6 +100,11 @@ javafx.preloader.type=none
|
||||
javafx.rebase.libs=false
|
||||
javafx.run.height=600
|
||||
javafx.run.width=800
|
||||
javafx.signing.blob=false
|
||||
javafx.signing.enabled=false
|
||||
javafx.signing.type=notsigned
|
||||
jlink.launcher=false
|
||||
jlink.launcher.name=JavaFX_CalebFontenot
|
||||
# Pre-JavaFX 2.0 WebStart is deactivated in JavaFX 2.0+ projects
|
||||
jnlp.enabled=false
|
||||
# Main class for Java launcher
|
||||
@ -103,6 +115,8 @@ manifest.custom.codebase=*
|
||||
manifest.custom.permissions=
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
native.bundling.enabled=false
|
||||
platform.active=JDK_1.8
|
||||
run.classpath=\
|
||||
${dist.jar}:\
|
||||
|
@ -22,5 +22,8 @@
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
|
||||
<definitions>./lib/nblibraries.properties</definitions>
|
||||
</libraries>
|
||||
</configuration>
|
||||
</project>
|
||||
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package javafx_calebfontenot;
|
||||
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class BidirectionalBindingDemo {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
DoubleProperty d1 = new SimpleDoubleProperty(1);
|
||||
DoubleProperty d2 = new SimpleDoubleProperty(2);
|
||||
|
||||
System.out.println("d1 is " + d1.getValue()
|
||||
+ " and d2 is " + d2.getValue());
|
||||
d1.bindBidirectional(d2);
|
||||
System.out.println("d1 is " + d1.getValue()
|
||||
+ " and d2 is " + d2.getValue());
|
||||
d1.setValue(50.1);
|
||||
System.out.println("d1 is " + d1.getValue()
|
||||
+ " and d2 is " + d2.getValue());
|
||||
d2.setValue(70.2);
|
||||
System.out.println("d1 is " + d1.getValue()
|
||||
+ " and d2 is " + d2.getValue());
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package javafx_calebfontenot;
|
||||
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class BindingDemo {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
DoubleProperty d1 = new SimpleDoubleProperty(1);
|
||||
DoubleProperty d2 = new SimpleDoubleProperty(1);
|
||||
|
||||
d1.bind(d2);
|
||||
System.out.println("d1 is " + d1.getValue()
|
||||
+ " and d2 is " + d2.getValue());
|
||||
d2.setValue(70.2);
|
||||
System.out.println("d1 is " + d1.getValue()
|
||||
+ " and d2 is" + d2.getValue());
|
||||
//d1.set(33); // remove comment to crash the program.
|
||||
// When you bind, you cannot change. It is like getting married.
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package javafx_calebfontenot;
|
||||
|
||||
import javafx.application.Application;
|
||||
import static javafx.application.Application.launch;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Checkerboard extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception
|
||||
{
|
||||
Pane pane = new Pane(); // Create a pane object
|
||||
Scene scene = new Scene(pane, 800, 800); // Create a scene object
|
||||
primaryStage.setScene(scene); // Set the stage scene to the scene object
|
||||
primaryStage.show(); // Make the window display on the screen
|
||||
Rectangle[][] r = new Rectangle[8][8];
|
||||
//Fill array with rectangle objects.
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
r[i][j] = new Rectangle();
|
||||
}
|
||||
}
|
||||
int j = 0;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
for (j = 0; j < 8; ++j) {
|
||||
r[i][j].setWidth(80);
|
||||
r[i][j].setHeight(80);
|
||||
if (j > 0) {
|
||||
r[i][j].setX(r[i][j - 1].getX() + 75);
|
||||
}
|
||||
if ((i + j) % 2 == 0) {
|
||||
r[i][j].setFill(Color.RED);
|
||||
} else {
|
||||
r[i][j].setFill(Color.BLACK);
|
||||
}
|
||||
r[i][j].setY((i + 1) * 75);
|
||||
pane.getChildren().add(r[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
launch(args);
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ public class ShowRectangle extends Application {
|
||||
Scene scene = new Scene(pane, 300, 200); // Create a scene object
|
||||
primaryStage.setScene(scene); // Set the stage scene to the scene object
|
||||
primaryStage.show(); // Make the window display on the screen
|
||||
Rectangle r = new Rectangle(30, 30, 88, 44);
|
||||
Rectangle r = new Rectangle(30, 30, 88, 44); // Crate a rectangle object with these dimentions.
|
||||
r.setX(30);
|
||||
r.setY(30);
|
||||
r.setStroke(Color.BLUE); // Set the rectangle outline to Blue
|
||||
|
3
Semester 2/Assignments/bruh/.bowerrc
Normal file
3
Semester 2/Assignments/bruh/.bowerrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"directory": "public_html/bower_components"
|
||||
}
|
9
Semester 2/Assignments/bruh/Gruntfile.js
Normal file
9
Semester 2/Assignments/bruh/Gruntfile.js
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/Gruntfile.js to edit this template
|
||||
*/
|
||||
module.exports = function (grunt) {
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
});
|
||||
};
|
13
Semester 2/Assignments/bruh/bower.json
Normal file
13
Semester 2/Assignments/bruh/bower.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "bruh",
|
||||
"version": "1.0.0",
|
||||
"main": "path/to/main.css",
|
||||
"ignore": [
|
||||
".jshintrc",
|
||||
"**/*.txt"
|
||||
],
|
||||
"dependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
}
|
||||
}
|
10
Semester 2/Assignments/bruh/gulpfile.js
Normal file
10
Semester 2/Assignments/bruh/gulpfile.js
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/gulpfile.js to edit this template
|
||||
*/
|
||||
|
||||
var gulp = require('gulp');
|
||||
|
||||
gulp.task('default', function () {
|
||||
// place code for your default task here
|
||||
});
|
5
Semester 2/Assignments/bruh/nbproject/project.properties
Normal file
5
Semester 2/Assignments/bruh/nbproject/project.properties
Normal file
@ -0,0 +1,5 @@
|
||||
file.reference.bruh-public_html=public_html
|
||||
file.reference.bruh-test=test
|
||||
files.encoding=UTF-8
|
||||
site.root.folder=${file.reference.bruh-public_html}
|
||||
test.folder=${file.reference.bruh-test}
|
9
Semester 2/Assignments/bruh/nbproject/project.xml
Normal file
9
Semester 2/Assignments/bruh/nbproject/project.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.web.clientproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/clientside-project/1">
|
||||
<name>bruh</name>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
8
Semester 2/Assignments/bruh/package.json
Normal file
8
Semester 2/Assignments/bruh/package.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "bruh",
|
||||
"version": "1.0.0",
|
||||
"keywords": ["util", "functional", "server", "client", "browser"],
|
||||
"author": "caleb",
|
||||
"contributors": [],
|
||||
"dependencies": {}
|
||||
}
|
24
Semester 2/Assignments/bruh/public_html/index.html
Normal file
24
Semester 2/Assignments/bruh/public_html/index.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this template
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>TODO supply a title</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<script>
|
||||
var x = 1;
|
||||
var y = 5;
|
||||
while (x < y)
|
||||
{
|
||||
alert("Good morning! " + x);
|
||||
x++;
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
<div>TODO write content</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,104 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Automobile.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}
|
||||
.ST2 {color: #9876aa}
|
||||
.ST3 {color: #ffc66d}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST1 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.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/Automobile.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.Objects;
|
||||
|
||||
<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> Automobile <span class="literal">implements</span> Comparable<Automobile> {
|
||||
|
||||
<span class="literal">private</span> String <span class="ST2">vin</span>;
|
||||
<span class="literal">private</span> CountryOfOrigin <span class="ST2">origin</span>;
|
||||
|
||||
<span class="literal">public</span> Automobile(String vin, CountryOfOrigin origin)
|
||||
{
|
||||
<span class="literal">this</span>.<span class="ST2">vin</span> = vin;
|
||||
<span class="literal">this</span>.<span class="ST2">origin</span> = origin;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> CountryOfOrigin <span class="ST3">getOrigin</span>()
|
||||
{
|
||||
<span class="literal">return</span> <span class="ST2">origin</span>;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">setOrigin</span>(CountryOfOrigin origin)
|
||||
{
|
||||
<span class="literal">this</span>.<span class="ST2">origin</span> = origin;
|
||||
}
|
||||
|
||||
|
||||
<span class="literal">public</span> String <span class="ST3">getVin</span>()
|
||||
{
|
||||
<span class="literal">return</span> <span class="ST2">vin</span>;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">setVin</span>(String vin)
|
||||
{
|
||||
<span class="literal">this</span>.<span class="ST2">vin</span> = vin;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> String <span class="ST3">toString</span>()
|
||||
{
|
||||
<span class="literal">return</span> <span class="string">"</span><span class="string">Automobile{</span><span class="string">"</span> + <span class="string">"</span><span class="string">vin=</span><span class="string">"</span> + <span class="ST2">vin</span> + <span class="string">"</span><span class="string">, origin=</span><span class="string">"</span> + <span class="ST2">origin</span> + <span class="string">'</span><span class="string">}</span><span class="string">'</span>;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">equals</span>(Object obj)
|
||||
{
|
||||
<span class="literal">if</span> (<span class="literal">this</span> == obj) {
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
<span class="literal">if</span> (obj == <span class="literal">null</span>) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">if</span> (getClass() != obj.getClass()) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">final</span> Automobile other = (Automobile) obj;
|
||||
<span class="literal">if</span> (!Objects.<span class="ST4">equals</span>(<span class="literal">t</span><span class="literal">his</span>.<span class="ST2">vin</span>, other.<span class="ST2">vin</span>)) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">return</span> Objects.<span class="ST4">equals</span>(<span class="literal">t</span><span class="literal">his</span>.<span class="ST2">origin</span>, other.<span class="ST2">origin</span>);
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">int</span> <span class="ST3">compareTo</span>(Automobile o)
|
||||
{
|
||||
<span class="literal">return</span> <span class="ST2">vin</span>.compareTo(o.<span class="ST2">vin</span>);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -0,0 +1,133 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>CountryOfOrigin.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}
|
||||
.ST2 {color: #9876aa}
|
||||
.ST3 {color: #ffc66d}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST5 {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}
|
||||
.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/CountryOfOrigin.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.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> CountryOfOrigin <span class="literal">implements</span> Cloneable, Comparable<CountryOfOrigin> {
|
||||
|
||||
<span class="literal">private</span> <span class="literal">char</span>[] <span class="ST2">country</span> = <span class="string">"</span><span class="string">USA</span><span class="string">"</span>.toCharArray();
|
||||
|
||||
<span class="literal">public</span> CountryOfOrigin() {}
|
||||
|
||||
<span class="literal">public</span> CountryOfOrigin(<span class="literal">char</span>[] country)
|
||||
{
|
||||
<span class="literal">this</span>.<span class="ST2">country</span> = country;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> String <span class="ST3">getCountry</span>()
|
||||
{
|
||||
<span class="literal">return</span> String.<span class="ST4">copyValueOf</span>(<span class="literal">t</span><span class="literal">his</span>.<span class="ST2">country</span>);
|
||||
}
|
||||
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">setCountry</span>(<span class="literal">char</span>[] country)
|
||||
{
|
||||
<span class="literal">this</span>.<span class="ST2">country</span> = country;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">changeOneLetter</span>(<span class="literal">int</span> index, <span class="literal">char</span> newLetter)
|
||||
{
|
||||
<span class="literal">if</span> (index >= <span class="literal">this</span>.<span class="ST2">country</span>.<span class="ST2">length</span> || index < <span class="number">0</span>) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">this</span>.<span class="ST2">country</span>[index] = newLetter;
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">equals</span>(Object obj)
|
||||
{
|
||||
<span class="literal">if</span> (<span class="literal">this</span> == obj) {
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
<span class="literal">if</span> (obj == <span class="literal">null</span>) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">if</span> (getClass() != obj.getClass()) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">final</span> CountryOfOrigin other = (CountryOfOrigin) obj;
|
||||
<span class="literal">return</span> Arrays.<span class="ST4">equals</span>(<span class="literal">t</span><span class="literal">his</span>.<span class="ST2">country</span>, other.<span class="ST2">country</span>);
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> String <span class="ST3">toString</span>()
|
||||
{
|
||||
<span class="literal">return</span> String.<span class="ST4">copyValueOf</span>(<span class="literal">t</span><span class="literal">his</span>.<span class="ST2">country</span>);
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">int</span> <span class="ST3">compareTo</span>(CountryOfOrigin o)
|
||||
{
|
||||
<span class="literal">return</span> String.<span class="ST4">copyValueOf</span>(<span class="literal">t</span><span class="literal">his</span>.<span class="ST2">country</span>).compareTo(String.<span class="ST4">copyValueOf</span>(o.<span class="ST2">country</span>));
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> Object <span class="ST3">clone</span>() {
|
||||
<span class="literal">return</span> <span class="literal">new</span> CountryOfOrigin(<span class="literal">n</span><span class="literal">ew</span> String(<span class="literal">t</span><span class="literal">his</span>.<span class="ST2">country</span>).toCharArray());
|
||||
}
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST5">main</span>(String[] args) <span class="literal">throws</span> CloneNotSupportedException
|
||||
{
|
||||
CountryOfOrigin c1 = <span class="literal">new</span> CountryOfOrigin();
|
||||
CountryOfOrigin c2 = <span class="literal">new</span> CountryOfOrigin(<span class="string">"</span><span class="string">GERMANY</span><span class="string">"</span>.toCharArray());
|
||||
CountryOfOrigin c3 = (CountryOfOrigin) c2.clone();
|
||||
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">c1 is: </span><span class="string">"</span> + c1);
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">c2 is: </span><span class="string">"</span> + c2);
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">c3 cloned of c2 is: </span><span class="string">"</span> + c3);
|
||||
|
||||
c3.changeOneLetter(<span class="number">0</span>, <span class="string">'</span><span class="string">J</span><span class="string">'</span>);
|
||||
c3.changeOneLetter(<span class="number">1</span>, <span class="string">'</span><span class="string">A</span><span class="string">'</span>);
|
||||
c3.changeOneLetter(<span class="number">2</span>, <span class="string">'</span><span class="string">P</span><span class="string">'</span>);
|
||||
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">c3 after changeOneLetter is: </span><span class="string">"</span> + c3);
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">if this displays GERMANY and not JAPMANY</span><span class="literal">\n</span><span class="string">your clone is deep: </span><span class="string">"</span> + c2);
|
||||
|
||||
System.<span class="ST6">out</span>.println(c1.compareTo(c2));
|
||||
System.<span class="ST6">out</span>.println(c1.compareTo(c3));
|
||||
System.<span class="ST6">out</span>.println(c1.equals(c2));
|
||||
System.<span class="ST6">out</span>.println(c1.equals(c3));
|
||||
System.<span class="ST6">out</span>.println(c2.getCountry());
|
||||
c2.setCountry(<span class="string">"</span><span class="string">ITALY</span><span class="string">"</span>.toCharArray());
|
||||
System.<span class="ST6">out</span>.println(c2.getCountry());
|
||||
System.<span class="ST6">out</span>.println(c1.getCountry());
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -0,0 +1,68 @@
|
||||
<!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<Automobile> {
|
||||
<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 < 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">"</span><span class="string">8</span><span class="string">"</span>, <span class="literal">new</span> CountryOfOrigin(<span class="string">"</span><span class="string">USA</span><span class="string">"</span>.toCharArray())));
|
||||
d.add(<span class="literal">new</span> Automobile(<span class="string">"</span><span class="string">1</span><span class="string">"</span>, <span class="literal">new</span> CountryOfOrigin(<span class="string">"</span><span class="string">GERMANY</span><span class="string">"</span>.toCharArray())));
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">THE ORIGINAL DEALERSHIP</span><span class="literal">\n</span><span class="string">"</span> + d);
|
||||
Dealership.<span class="ST4">sortByVin</span>(d);
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="string">THE SORTED BY VIN DEALERSHIP</span><span class="literal">\n</span><span class="string">"</span> + d);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
Binary file not shown.
15
Semester 2/Exams/Exam2-Practice1_CalebFontenot/pom.xml
Normal file
15
Semester 2/Exams/Exam2-Practice1_CalebFontenot/pom.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.calebfontenot</groupId>
|
||||
<artifactId>Exam2-Practice1_CalebFontenot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<exec.mainClass>com.calebfontenot.exam2.practice_calebfontenot.Exam2Practice_CalebFontenot</exec.mainClass>
|
||||
</properties>
|
||||
<name>Exam2-Practice1_CalebFontenot</name>
|
||||
</project>
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.exam2.practice_calebfontenot;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Automobile implements Comparable<Automobile> {
|
||||
|
||||
private String vin;
|
||||
private CountryOfOrigin origin;
|
||||
|
||||
public Automobile(String vin, CountryOfOrigin origin)
|
||||
{
|
||||
this.vin = vin;
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
public CountryOfOrigin getOrigin()
|
||||
{
|
||||
return origin;
|
||||
}
|
||||
|
||||
public void setOrigin(CountryOfOrigin origin)
|
||||
{
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
|
||||
public String getVin()
|
||||
{
|
||||
return vin;
|
||||
}
|
||||
|
||||
public void setVin(String vin)
|
||||
{
|
||||
this.vin = vin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Automobile{" + "vin=" + vin + ", origin=" + origin + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Automobile other = (Automobile) obj;
|
||||
if (!Objects.equals(this.vin, other.vin)) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(this.origin, other.origin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Automobile o)
|
||||
{
|
||||
return vin.compareTo(o.vin);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.exam2.practice_calebfontenot;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class CountryOfOrigin implements Cloneable, Comparable<CountryOfOrigin> {
|
||||
|
||||
private char[] country = "USA".toCharArray();
|
||||
|
||||
public CountryOfOrigin() {}
|
||||
|
||||
public CountryOfOrigin(char[] country)
|
||||
{
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getCountry()
|
||||
{
|
||||
return String.copyValueOf(this.country);
|
||||
}
|
||||
|
||||
public void setCountry(char[] country)
|
||||
{
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public boolean changeOneLetter(int index, char newLetter)
|
||||
{
|
||||
if (index >= this.country.length || index < 0) {
|
||||
return false;
|
||||
}
|
||||
this.country[index] = newLetter;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final CountryOfOrigin other = (CountryOfOrigin) obj;
|
||||
return Arrays.equals(this.country, other.country);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.copyValueOf(this.country);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(CountryOfOrigin o)
|
||||
{
|
||||
return String.copyValueOf(this.country).compareTo(String.copyValueOf(o.country));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new CountryOfOrigin(new String(this.country).toCharArray());
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws CloneNotSupportedException
|
||||
{
|
||||
CountryOfOrigin c1 = new CountryOfOrigin();
|
||||
CountryOfOrigin c2 = new CountryOfOrigin("GERMANY".toCharArray());
|
||||
CountryOfOrigin c3 = (CountryOfOrigin) c2.clone();
|
||||
|
||||
System.out.println("c1 is: " + c1);
|
||||
System.out.println("c2 is: " + c2);
|
||||
System.out.println("c3 cloned of c2 is: " + c3);
|
||||
|
||||
c3.changeOneLetter(0, 'J');
|
||||
c3.changeOneLetter(1, 'A');
|
||||
c3.changeOneLetter(2, 'P');
|
||||
|
||||
System.out.println("c3 after changeOneLetter is: " + c3);
|
||||
System.out.println("if this displays GERMANY and not JAPMANY\nyour clone is deep: " + c2);
|
||||
|
||||
System.out.println(c1.compareTo(c2));
|
||||
System.out.println(c1.compareTo(c3));
|
||||
System.out.println(c1.equals(c2));
|
||||
System.out.println(c1.equals(c3));
|
||||
System.out.println(c2.getCountry());
|
||||
c2.setCountry("ITALY".toCharArray());
|
||||
System.out.println(c2.getCountry());
|
||||
System.out.println(c1.getCountry());
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.exam2.practice_calebfontenot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Dealership extends ArrayList<Automobile> {
|
||||
/** Sorts the inherited ArrayList of Automobiles
|
||||
* into ascending order by vin number.
|
||||
* @param d the Dealership of Automobiles
|
||||
*/
|
||||
public static void sortByVin(Dealership d) { //java.util.Collections.sort() could do all of this in a single line
|
||||
Object[] dealershipArray = d.toArray();
|
||||
Arrays.sort(dealershipArray);
|
||||
d.clear();
|
||||
for (int i = 0; i < dealershipArray.length; ++i) {
|
||||
d.add((Automobile) dealershipArray[i]);
|
||||
}
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Dealership d = new Dealership();
|
||||
|
||||
d.add(new Automobile("8", new CountryOfOrigin("USA".toCharArray())));
|
||||
d.add(new Automobile("1", new CountryOfOrigin("GERMANY".toCharArray())));
|
||||
System.out.println("THE ORIGINAL DEALERSHIP\n" + d);
|
||||
Dealership.sortByVin(d);
|
||||
System.out.println("\nTHE SORTED BY VIN DEALERSHIP\n" + d);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
*/
|
||||
|
||||
package com.calebfontenot.exam2.practice_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Exam2Practice_CalebFontenot {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1,125 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Automobile.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}
|
||||
.ST2 {color: #9876aa}
|
||||
.ST3 {color: #ffc66d}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST5 {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}
|
||||
.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/Assignments/Exam2-Practice2_CalebFontenot/src/main/java/com/calebfontenot/exam2/practice2_calebfontenot/Automobile.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.practice2_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Objects;
|
||||
|
||||
<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> Automobile <span class="literal">extends</span> Vehicle <span class="literal">implements</span> Cloneable{
|
||||
|
||||
<span class="literal">private</span> String <span class="ST2">make</span>;
|
||||
|
||||
<span class="literal">public</span> Automobile(String make)
|
||||
{
|
||||
<span class="literal">this</span>.<span class="ST2">make</span> = make;
|
||||
}
|
||||
<span class="literal">public</span> Automobile(String make, String vin)
|
||||
{
|
||||
<span class="literal">super</span>(vin);
|
||||
<span class="literal">this</span>.<span class="ST2">make</span> = make;
|
||||
}
|
||||
<span class="literal">public</span> String <span class="ST3">getMake</span>() { <span class="literal">return</span> <span class="ST2">make</span>; }
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">setMake</span>(String make) { <span class="literal">this</span>.<span class="ST2">make</span> = make; }
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">int</span> <span class="ST3">compareTo</span>(Vehicle o)
|
||||
{
|
||||
<span class="literal">return</span> <span class="literal">this</span>.getVin().compareTo(o.getVin());
|
||||
}
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">equals</span>(Object obj)
|
||||
{
|
||||
<span class="literal">if</span> (<span class="literal">this</span> == obj) {
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
<span class="literal">if</span> (obj == <span class="literal">null</span>) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">if</span> (getClass() != obj.getClass()) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">final</span> Automobile other = (Automobile) obj;
|
||||
<span class="literal">boolean</span> isSameObjectType = Objects.<span class="ST4">equals</span>(<span class="literal">t</span><span class="literal">his</span>.<span class="ST2">make</span>, other.<span class="ST2">make</span>);
|
||||
<span class="literal">if</span> (isSameObjectType) {
|
||||
<span class="literal">if</span> (<span class="literal">this</span>.<span class="ST2">make</span>.compareTo(other.<span class="ST2">make</span>) == <span class="number">0</span> && (<span class="literal">this</span>.getVin().compareTo(other.getVin()) == <span class="number">0</span>)) {
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
} <span class="literal">else</span> {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
} <span class="literal">else</span> {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
<span class="literal">protected</span> Object <span class="ST3">clone</span>() <span class="literal">throws</span> CloneNotSupportedException {
|
||||
String make = <span class="literal">new</span> String(<span class="literal">t</span><span class="literal">his</span>.getMake());
|
||||
String vim = <span class="literal">new</span> String(<span class="literal">t</span><span class="literal">his</span>.getVin());
|
||||
Automobile clonedAuto = <span class="literal">new</span> Automobile(make, vim);
|
||||
<span class="literal">return</span> clonedAuto;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> String <span class="ST3">toString</span>()
|
||||
{
|
||||
<span class="literal">return</span> <span class="literal">super</span>.toString() + <span class="string">"</span><span class="literal">\n</span><span class="string">"</span> + <span class="string">"</span><span class="string">Automobile{</span><span class="string">"</span> + <span class="string">"</span><span class="string">make=</span><span class="string">"</span> + <span class="ST2">make</span> + <span class="string">'</span><span class="string">}</span><span class="string">'</span>;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST5">main</span>(String[] args) <span class="literal">throws</span> CloneNotSupportedException
|
||||
{
|
||||
Automobile johnsBeemer = <span class="literal">new</span> Automobile (<span class="string">"</span><span class="string">BMW</span><span class="string">"</span>, <span class="string">"</span><span class="string">vin1BMW</span><span class="string">"</span>);
|
||||
Automobile marysBeemer = <span class="literal">new</span> Automobile (<span class="string">"</span><span class="string">BMW</span><span class="string">"</span>, <span class="string">"</span><span class="string">vin2BMW</span><span class="string">"</span>);
|
||||
|
||||
Automobile johnsClonedBeemer = (Automobile) johnsBeemer.clone();
|
||||
|
||||
System.<span class="ST6">out</span>.println(johnsBeemer + <span class="string">"</span><span class="literal">\n</span><span class="string">"</span>);
|
||||
System.<span class="ST6">out</span>.println(marysBeemer + <span class="string">"</span><span class="literal">\n</span><span class="string">"</span>);
|
||||
System.<span class="ST6">out</span>.println(johnsClonedBeemer + <span class="string">"</span><span class="literal">\n</span><span class="string">"</span>);
|
||||
|
||||
|
||||
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">John</span><span class="literal">\'</span><span class="string">s beemer EQUALS Mary</span><span class="literal">\'</span><span class="string">s beemer --> </span><span class="string">"</span> + johnsBeemer.equals(marysBeemer));
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">John</span><span class="literal">\'</span><span class="string">s beemer EQUALS John</span><span class="literal">\'</span><span class="string">s beemer --> </span><span class="string">"</span> + johnsBeemer.equals(johnsClonedBeemer));
|
||||
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">John</span><span class="literal">\'</span><span class="string">s beemer COMPARE_TO John</span><span class="literal">\'</span><span class="string">s cloned beemer --> </span><span class="string">"</span> + johnsBeemer.compareTo(johnsClonedBeemer));
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">John</span><span class="literal">\'</span><span class="string">s beemer COMPARE_TO Mary</span><span class="literal">\'</span><span class="string">s beemer --> </span><span class="string">"</span> +johnsBeemer.compareTo(marysBeemer));
|
||||
|
||||
System.<span class="ST6">out</span>.println(<span class="string">"</span><span class="string">John</span><span class="literal">\'</span><span class="string">s beemer EQUALS Airplane --> </span><span class="string">"</span> + johnsBeemer.equals(<span class="literal">new</span> Airplane()));
|
||||
}
|
||||
}
|
||||
|
||||
<span class="literal">class</span> Airplane {}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -0,0 +1,69 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Vehicle.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}
|
||||
.ST2 {color: #9876aa}
|
||||
.ST3 {color: #ffc66d}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST1 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.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/Assignments/Exam2-Practice2_CalebFontenot/src/main/java/com/calebfontenot/exam2/practice2_calebfontenot/Vehicle.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.practice2_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Objects;
|
||||
|
||||
<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">abstract</span> <span class="literal">public</span> <span class="literal">class</span> Vehicle <span class="literal">implements</span> Cloneable, Comparable<Vehicle> {
|
||||
|
||||
<span class="literal">private</span> String <span class="ST2">vin</span>;
|
||||
<span class="literal">public</span> Vehicle(){}
|
||||
<span class="literal">public</span> Vehicle(String vin) {<span class="literal">this</span>.<span class="ST2">vin</span> = vin;}
|
||||
<span class="literal">public</span> String <span class="ST3">getVin</span>() { <span class="literal">return</span> <span class="ST2">vin</span>; }
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">setVin</span>(String vin) { <span class="literal">this</span>.<span class="ST2">vin</span> = vin; }
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> String <span class="ST3">toString</span>()
|
||||
{ <span class="literal">return</span> <span class="string">"</span><span class="string">Vehicle{</span><span class="string">"</span> + <span class="string">"</span><span class="string">vin=</span><span class="string">"</span> + <span class="ST2">vin</span> + <span class="string">'</span><span class="string">}</span><span class="string">'</span>; }
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">equals</span>(Object obj)
|
||||
{
|
||||
<span class="literal">if</span> (<span class="literal">this</span> == obj) {
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
<span class="literal">if</span> (obj == <span class="literal">null</span>) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">if</span> (getClass() != obj.getClass()) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">final</span> Vehicle other = (Vehicle) obj;
|
||||
<span class="literal">return</span> Objects.<span class="ST4">equals</span>(<span class="literal">t</span><span class="literal">his</span>.<span class="ST2">vin</span>, other.<span class="ST2">vin</span>);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
Binary file not shown.
14
Semester 2/Exams/Exam2-Practice2_CalebFontenot/pom.xml
Normal file
14
Semester 2/Exams/Exam2-Practice2_CalebFontenot/pom.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.calebfontenot</groupId>
|
||||
<artifactId>Exam2-Practice2_CalebFontenot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<exec.mainClass>com.calebfontenot.exam2.practice2_calebfontenot.Exam2Practice2_CalebFontenot</exec.mainClass>
|
||||
</properties>
|
||||
</project>
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.exam2.practice2_calebfontenot;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Automobile extends Vehicle implements Cloneable{
|
||||
|
||||
private String make;
|
||||
|
||||
public Automobile(String make)
|
||||
{
|
||||
this.make = make;
|
||||
}
|
||||
public Automobile(String make, String vin)
|
||||
{
|
||||
super(vin);
|
||||
this.make = make;
|
||||
}
|
||||
public String getMake() { return make; }
|
||||
public void setMake(String make) { this.make = make; }
|
||||
@Override
|
||||
public int compareTo(Vehicle o)
|
||||
{
|
||||
return this.getVin().compareTo(o.getVin());
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Automobile other = (Automobile) obj;
|
||||
boolean isSameObjectType = Objects.equals(this.make, other.make);
|
||||
if (isSameObjectType) {
|
||||
if (this.make.compareTo(other.make) == 0 && (this.getVin().compareTo(other.getVin()) == 0)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
String make = new String(this.getMake());
|
||||
String vim = new String(this.getVin());
|
||||
Automobile clonedAuto = new Automobile(make, vim);
|
||||
return clonedAuto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString() + "\n" + "Automobile{" + "make=" + make + '}';
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws CloneNotSupportedException
|
||||
{
|
||||
Automobile johnsBeemer = new Automobile ("BMW", "vin1BMW");
|
||||
Automobile marysBeemer = new Automobile ("BMW", "vin2BMW");
|
||||
|
||||
Automobile johnsClonedBeemer = (Automobile) johnsBeemer.clone();
|
||||
|
||||
System.out.println(johnsBeemer + "\n");
|
||||
System.out.println(marysBeemer + "\n");
|
||||
System.out.println(johnsClonedBeemer + "\n");
|
||||
|
||||
|
||||
|
||||
System.out.println("John\'s beemer EQUALS Mary\'s beemer --> " + johnsBeemer.equals(marysBeemer));
|
||||
System.out.println("John\'s beemer EQUALS John\'s beemer --> " + johnsBeemer.equals(johnsClonedBeemer));
|
||||
|
||||
System.out.println("John\'s beemer COMPARE_TO John\'s cloned beemer --> " + johnsBeemer.compareTo(johnsClonedBeemer));
|
||||
System.out.println("John\'s beemer COMPARE_TO Mary\'s beemer --> " +johnsBeemer.compareTo(marysBeemer));
|
||||
|
||||
System.out.println("John\'s beemer EQUALS Airplane --> " + johnsBeemer.equals(new Airplane()));
|
||||
}
|
||||
}
|
||||
|
||||
class Airplane {}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
*/
|
||||
|
||||
package com.calebfontenot.exam2.practice2_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Exam2Practice2_CalebFontenot {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package com.calebfontenot.exam2.practice2_calebfontenot;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Automobile extends Vehicle implements Cloneable{
|
||||
|
||||
private String make;
|
||||
|
||||
public Automobile(String make)
|
||||
{
|
||||
this.make = make;
|
||||
}
|
||||
public Automobile(String make, String vin)
|
||||
{
|
||||
super(vin);
|
||||
this.make = make;
|
||||
}
|
||||
public String getMake() { return make; }
|
||||
public void setMake(String make) { this.make = make; }
|
||||
@Override
|
||||
public int compareTo(Vehicle o)
|
||||
{
|
||||
return this.getVin().compareTo(o.getVin());
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Automobile other = (Automobile) obj;
|
||||
boolean isSameObjectType = Objects.equals(this.make, other.make);
|
||||
if (isSameObjectType) {
|
||||
if (this.make.compareTo(other.make) == 0 && (this.getVin().compareTo(other.getVin()) == 0)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
String make = new String(this.getMake());
|
||||
String vim = new String(this.getVin());
|
||||
Automobile clonedAuto = new Automobile(make, vim);
|
||||
return clonedAuto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString() + "\n" + "Automobile{" + "make=" + make + '}';
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws CloneNotSupportedException
|
||||
{
|
||||
Automobile johnsBeemer = new Automobile ("BMW", "vin1BMW");
|
||||
Automobile marysBeemer = new Automobile ("BMW", "vin2BMW");
|
||||
|
||||
Automobile johnsClonedBeemer = (Automobile) johnsBeemer.clone();
|
||||
|
||||
System.out.println(johnsBeemer + "\n");
|
||||
System.out.println(marysBeemer + "\n");
|
||||
System.out.println(johnsClonedBeemer + "\n");
|
||||
|
||||
|
||||
|
||||
System.out.println("John\'s beemer EQUALS Mary\'s beemer --> " + johnsBeemer.equals(marysBeemer));
|
||||
System.out.println("John\'s beemer EQUALS John\'s beemer --> " + johnsBeemer.equals(johnsClonedBeemer));
|
||||
|
||||
System.out.println("John\'s beemer COMPARE_TO John\'s cloned beemer --> " + johnsBeemer.compareTo(johnsClonedBeemer));
|
||||
System.out.println("John\'s beemer COMPARE_TO Mary\'s beemer --> " +johnsBeemer.compareTo(marysBeemer));
|
||||
|
||||
System.out.println("John\'s beemer EQUALS Airplane --> " + johnsBeemer.equals(new Airplane()));
|
||||
}
|
||||
}
|
||||
|
||||
abstract public class Vehicle implements Cloneable, Comparable<Vehicle> {
|
||||
|
||||
private String vin;
|
||||
public Vehicle(){}
|
||||
public Vehicle(String vin) {this.vin = vin;}
|
||||
public String getVin() { return vin; }
|
||||
public void setVin(String vin) { this.vin = vin; }
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{ return "Vehicle{" + "vin=" + vin + '}'; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Vehicle other = (Vehicle) obj;
|
||||
return Objects.equals(this.vin, other.vin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Airplane {}
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.exam2.practice2_calebfontenot;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
abstract public class Vehicle implements Cloneable, Comparable<Vehicle> {
|
||||
|
||||
private String vin;
|
||||
public Vehicle(){}
|
||||
public Vehicle(String vin) {this.vin = vin;}
|
||||
public String getVin() { return vin; }
|
||||
public void setVin(String vin) { this.vin = vin; }
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{ return "Vehicle{" + "vin=" + vin + '}'; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Vehicle other = (Vehicle) obj;
|
||||
return Objects.equals(this.vin, other.vin);
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,4 @@
|
||||
com/calebfontenot/exam2/practice2_calebfontenot/Automobile.class
|
||||
com/calebfontenot/exam2/practice2_calebfontenot/Exam2Practice2_CalebFontenot.class
|
||||
com/calebfontenot/exam2/practice2_calebfontenot/Airplane.class
|
||||
com/calebfontenot/exam2/practice2_calebfontenot/Vehicle.class
|
@ -0,0 +1,3 @@
|
||||
/home/caleb/ASDV-Java/Semester 2/Assignments/Exam2-Practice2_CalebFontenot/src/main/java/com/calebfontenot/exam2/practice2_calebfontenot/Exam2Practice2_CalebFontenot.java
|
||||
/home/caleb/ASDV-Java/Semester 2/Assignments/Exam2-Practice2_CalebFontenot/src/main/java/com/calebfontenot/exam2/practice2_calebfontenot/Vehicle.java
|
||||
/home/caleb/ASDV-Java/Semester 2/Assignments/Exam2-Practice2_CalebFontenot/src/main/java/com/calebfontenot/exam2/practice2_calebfontenot/Automobile.java
|
BIN
Semester 2/ZIPs/Exam2-Practice1_CalebFontenot.zip
Normal file
BIN
Semester 2/ZIPs/Exam2-Practice1_CalebFontenot.zip
Normal file
Binary file not shown.
BIN
Semester 2/ZIPs/Exam2-Practice2_CalebFontenot.zip
Normal file
BIN
Semester 2/ZIPs/Exam2-Practice2_CalebFontenot.zip
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user