/home/caleb/ASDV-Java/Semester 2/Exams/Exam2-Practice_CalebFontenot/src/main/java/com/calebfontenot/exam2/practice_calebfontenot/Dealership.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package com.calebfontenot.exam2.practice_calebfontenot;
import java.util.ArrayList;
import java.util.Arrays;
@author
public class Dealership extends ArrayList<Automobile> {
@param d
public static void sortByVin(Dealership d) {
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);
}
}