[1373] PR review fixes

Move hasRecoveryDevice to RocketComponent and reimplement
FlightConfiguration version to check for FlightConfiguration errors.
This commit is contained in:
Peter Tsongalis 2022-06-12 16:06:58 -07:00
parent f5cc1f61bf
commit 6c475645d4
2 changed files with 18 additions and 12 deletions

View File

@ -549,21 +549,14 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
} }
/** /**
* Return true if a rocket has a configured Recovery Device * Return true if rocket has a RecoveryDevice
*/ */
public boolean hasRecoveryDevice() { public boolean hasRecoveryDevice() {
Rocket rkt = this.getRocket(); if (fcid.hasError()) {
RocketComponent nextComponent = rkt.getNextComponent(); return false;
}
while(nextComponent != null) { return this.getRocket().hasRecoveryDevice();
if(nextComponent instanceof RecoveryDevice) {
return true;
}
nextComponent = nextComponent.getNextComponent();
}
return false;
} }
/////////////// Helper methods /////////////// /////////////// Helper methods ///////////////

View File

@ -427,6 +427,19 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
} }
} }
/**
* Return true if any of this component's children are a RecoveryDevice
*/
public boolean hasRecoveryDevice() {
Iterator<RocketComponent> iterator = this.iterator();
while (iterator.hasNext()) {
RocketComponent child = iterator.next();
if (child instanceof RecoveryDevice) {
return true;
}
}
return false;
}
////////////// Methods that may not be overridden //////////// ////////////// Methods that may not be overridden ////////////