Added protected copy constructor which makes a deep copy. This is used in the androi...
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Wed, 16 May 2012 06:17:22 +0000 (06:17 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Wed, 16 May 2012 06:17:22 +0000 (06:17 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@686 180e2498-e6e9-4542-8430-84ac67f01cd8

core/src/net/sf/openrocket/motor/ThrustCurveMotor.java

index e1ba1d77ca6c7b6f02d8aa4e5870e8a39b6fd107..8467c0a3ae9f5bfaeb261c6046b555bf08445343 100644 (file)
@@ -43,6 +43,31 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor> {
        private double averageThrust;
        private double totalImpulse;
        
+       /**
+        * Deep copy constructor.
+        * Constructs a new ThrustCurveMotor from an existing ThrustCurveMotor.
+        * @param m
+        */
+       protected ThrustCurveMotor( ThrustCurveMotor m ) {
+               this.digest = m.digest;
+               this.manufacturer = m.manufacturer;
+               this.designation = m.designation;
+               this.description = m.description;
+               this.type = m.type;
+               this.delays = Arrays.copyOf(m.delays, m.delays.length);
+               this.diameter = m.diameter;
+               this.length = m.length;
+               this.time = Arrays.copyOf(m.time, m.time.length);
+               this.thrust = Arrays.copyOf(m.thrust, m.thrust.length);
+               this.cg = new Coordinate[ m.cg.length ];
+               for( int i = 0; i< cg.length; i++ ) {
+                       this.cg[i] = m.cg[i].clone();
+               }
+               this.maxThrust = m.maxThrust;
+               this.burnTime = m.burnTime;
+               this.averageThrust = m.averageThrust;
+               this.totalImpulse = m.totalImpulse;
+       }
        
        /**
         * Sole constructor.  Sets all the properties of the motor.