From 98cef5e9a772602d42acfcf233838c760424db9a Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Thu, 13 Feb 2025 18:00:17 +1100 Subject: initial commit --- comp2511/blackout/RelaySatellite.java | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 comp2511/blackout/RelaySatellite.java (limited to 'comp2511/blackout/RelaySatellite.java') diff --git a/comp2511/blackout/RelaySatellite.java b/comp2511/blackout/RelaySatellite.java new file mode 100644 index 0000000..1087db8 --- /dev/null +++ b/comp2511/blackout/RelaySatellite.java @@ -0,0 +1,66 @@ +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. + } +} -- cgit v1.2.3