package unsw.blackout; import java.util.Optional; import unsw.utils.Angle; public class RelaySatellite extends SatelliteBase { public RelaySatellite(String satelliteID, double height, Angle position) { super(satelliteID, height, position); } @ Override final public double getVelocity() { return 1_500.0; } @ Override final public double getRange() { return 300_000.0; } /** * Relay satellites oscillate between 140 and 90 degrees, so we override move to incorporate this behaviour. */ private boolean is_counterclockwise = true; @ Override final public void move() { double current = this.getAngle().toDegrees(); if (current < 140.0 || current > 190.0) { if (current > 190.0 && current < 345.0) { is_counterclockwise = false; } else { is_counterclockwise = true; } } double offset = this.getMoveOffsetRadians(); double rposition = (this.getAngle().toRadians() + (is_counterclockwise ? offset : -offset)) % Math.toRadians(360.0); setAngle(Angle.fromRadians(rposition + (rposition < 0 ? Math.toRadians(360.0) : 0))); } @ Override final protected boolean isSupportedDeviceType(String type) { return true; // Supports all devices! } @ Override final protected boolean canRelay() { return true; } @ Override final protected Optional getFileStoreLimit() { return Optional.of(0); // Cannot store any files! } @ Override final protected Optional getByteStoreLimit() { return Optional.of(0); // Cannot store any bytes! } @ Override final protected Optional getByteDownloadSpeed() { return Optional.empty(); // Infinite download speed } @ Override final protected Optional getByteUploadSpeed() { return Optional.empty(); // Infinite upload speed. } }