'Deep copy of Object array that includes multiple classes in Java?

I'm currently struggling to create a deep copy of my Object array in Java. This Object array includes values from three different classes, with only one of these classes being a subclass of the other. The classes are listed as follows:

//First superclass
package Plane;
public class Plane {
    
    
     private String brand;
     private double price; 
     private int horsepower;
    
     
    public Plane() {
        brand = "test";
        price = 50000.99; 
        horsepower = 500;
    }
    
    public Plane(String planeBrand, double planePrice, int planePower) {
        this.brand = planeBrand;
        this.price = planePrice;
        this.horsepower = planePower;
    }
    
    public String getBrand() {
        return this.brand;
    }
    public void setBrand(String planeBrand) {
        this.brand = planeBrand;
    }
    
    public double getPrice() {
        return this.price;
    }
    
    public void setPrice(double planePrice) {
        this.price = planePrice;
    }
    
    public int getPower() {
        return this.horsepower;
    }
    
    public void setPower(int planePower) {
        this.horsepower = planePower;
    }
    
    //COPY CONSTRUCTOR
    public Airplane(Plane plane) {
        this.brand = plane.getBrand();
        this.price = plane.getPrice();
        this.horsepower = plane.getPower();
    }
    
    public String toString() {
        return "The airplane is manufactured by " + this.brand + " and costs $" + this.price + ". It has " + this.horsepower + " horsepower.";
    }

    public boolean equals(Plane plane) {
        if (!(plane instanceof Plane) || plane == null) {
                return false;
            } else if (this.brand != plane.getBrand() || this.price != plane.getPrice() || this.horsepower != plane.getPower()) {
                    return false;
                } else {
                    return true;
                }
            }
        }
//Second class
package Boat;
public class Boat {

    private double weight;
    private double price;
    
    public Boat() {
        weight = 3949.5;
        price = 64000;
    }
    
    public Boat(double boatWeight, double boatPrice) {
        weight = boatWeight;
        price = boatPrice;
    }
    
    public double getWeight() {
        return this.weight;
    }
    
    public void setWeight(double boatWeight) {
        this.weight = boatWeight;
    }
    
    public double getPrice() {
        return this.price;
    }

    public void setPrice(double boatPrice) {
        this.price = boatPrice;
    }
    
    //COPY CONSTRUCTOR
    public Boat(Boat boat) {
        this.weight = boat.getWeight();
        this.price = boat.getPrice();
    }
    
    public String toString() {
        return "This boat weighs " + this.getWeight() + "kg and costs $" + this.getPrice() + ".";
    }
    
    public boolean equals(Boat boat) {
        if (!(boat instanceof Boat) || boat == null) {
            return false;
        } else if (this.price != boat.price || this.weight != boat.weight) {
            return false;
        } else {
            return true;
        }
    }
    
}
//Third class which extends Plane
package Heli;
import Plane.Plane;

public class Heli extends Plane{
    
    private int cylinders;
    private int year;
    private int capacity;
    
    public Heli() {
        cylinders = 6;
        year = 2018;
        capacity = 35;
    }

    public Heli(String planeBrand, double planePrice, int power, int cylinders, int year, int capacity) {
        super(planeBrand, planePrice, power);
        this.cylinders = cylinders;
        this.year = year;
        this.capacity = capacity;
    }

    public int getCylinders() {
        return this.cylinders;
    }
    
    public void setCylinders(int cylinders) {
        this.cylinders = cylinders;
    }
    
    public int getYear() {
        return this.year;
    }
    
    public void setYear(int year) {
        this.year = year;
    }
    
    public int getCapacity() {
        return this.capacity;
    }
    
    public void setCapacity(int capacity) {
        this.capacity = capacity;
    }
    
    //COPY CONSTRUCTOR
    public Helicopter(Helicopter helicopter) {
        super(helicopter);
        this.cylinders = helicopter.cylinders;
        this.year = helicopter.year;
        this.capacity = helicopter.capacity;
    }
    
    public String toString() {
        return "This heli is manufactured by " + super.getBrand() + " and costs $" + super.getPrice() + ". It has " + super.getPower() + " horsepower. It was manufactured in " + getYear() + ", has " + getCylinders() + " cylinders and has a total carrying capacity of " + getCapacity() + " lbs.";
    }

    public boolean equals(Heli heli) {
        if (!(heli instanceof Heli) || heli == null) {
            return false;
        } else if (this.cylinders != heli.getCylinders() || this.year != heli.getYear() || this.capacity != heli.getCapacity() || !(super.equals(heli))) {
            return false;
        } else {
            return true;
        }
    }
    
}
//Driver class where my copy takes place
public class Driver {


    private static Object[] newMixedArray = new Object[3];

    //THIS IS WHERE MY COPY ARRAY NEEDS TO BE IMPLEMENTED
    public static void copyObjects(Object[] newMixedArray) {
        Object[] copyArray = new Object[newMixedArray.length];
    
    }


    public static void main(String[] args) {
        
        newMixedArray[0] = new Plane("Bombardier", 50000000, 4000);
        newMixedArray[1] = new Boat("Boeing", 8500000.75, 8500);
        newMixedArray[2] = new Heli("Glastron", 250500.99, 837, 8, 2020, 35);
        

        copyObjects(newMixedArray);

    }

}

Now the kicker is that I cannot use clone() to create my copy array. At first, I created a simple loop to copy my original array into another array called "copyArray" and print out the values, however it came to my attention that this was simply a shallow copy and not a deep copy. I've been wracking my brain for the last several days trying to find a solution but have come up empty, especially since most answers I've found online don't seem to apply to situations with multiple classes.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source