aboutsummaryrefslogtreecommitdiff
path: root/comp2511/blackout/RelaySatellite.java
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-13 18:00:17 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-13 18:00:17 +1100
commit98cef5e9a772602d42acfcf233838c760424db9a (patch)
tree5277fa1d7cc0a69a0f166fcbf10fd320f345f049 /comp2511/blackout/RelaySatellite.java
initial commit
Diffstat (limited to 'comp2511/blackout/RelaySatellite.java')
-rw-r--r--comp2511/blackout/RelaySatellite.java66
1 files changed, 66 insertions, 0 deletions
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<Integer> getFileStoreLimit() {
+ return Optional.of(0); // Cannot store any files!
+ }
+ @ Override
+ final protected Optional<Integer> getByteStoreLimit() {
+ return Optional.of(0); // Cannot store any bytes!
+ }
+ @ Override
+ final protected Optional<Integer> getByteDownloadSpeed() {
+ return Optional.empty(); // Infinite download speed
+ }
+ @ Override
+ final protected Optional<Integer> getByteUploadSpeed() {
+ return Optional.empty(); // Infinite upload speed.
+ }
+}