Reset author name to chosen name

This commit is contained in:
2025-10-19 22:02:41 -05:00
parent 168b35c94a
commit 578c33de70
316 changed files with 17381 additions and 0 deletions

View File

@@ -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.chloefontenot.exam2.practice_chloefontenot;
import java.util.Objects;
/**
*
* @author chloe
*/
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);
}
}

View File

@@ -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.chloefontenot.exam2.practice_chloefontenot;
import java.util.Arrays;
/**
*
* @author chloe
*/
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());
}
}

View File

@@ -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.chloefontenot.exam2.practice_chloefontenot;
import java.util.ArrayList;
import java.util.Arrays;
/**
*
* @author chloe
*/
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);
}
}

View File

@@ -0,0 +1,16 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
*/
package com.chloefontenot.exam2.practice_chloefontenot;
/**
*
* @author chloe
*/
public class Exam2Practice_ChloeFontenot {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}