Finished AB5

This commit is contained in:
2022-05-07 13:20:59 +02:00
parent a075544fe2
commit 34c2ac91c6
9 changed files with 384 additions and 116 deletions

View File

@@ -6,8 +6,7 @@ import codedraw.CodeDraw;
*/
public class NamedBodyForcePair implements CosmicSystem {
private final String name;
private final Body body;
private final NamedBody body;
private final Vector3 force = new Vector3();
/**
@@ -15,27 +14,30 @@ public class NamedBodyForcePair implements CosmicSystem {
* is initialized with a zero vector.
*/
public NamedBodyForcePair(String name, double mass, Vector3 massCenter, Vector3 currentMovement) {
this(name, new Body(mass, massCenter, currentMovement));
this(new NamedBody(name, mass, massCenter, currentMovement));
}
public NamedBodyForcePair(String name, Body b) {
this.body = b;
this.name = name;
public NamedBodyForcePair(String name, Body body) {
this(new NamedBody(name, body));
}
public NamedBodyForcePair(NamedBody body) {
this.body = body;
}
public NamedBodyForcePair(NamedBodyForcePair other) {
this(other.name, new Body(other.body));
this(new NamedBody(other.body));
}
public Body getBody() {
return body;
return body.getBody();
}
/**
* Returns the name of the body.
*/
public String getName() {
return name;
return body.getName();
}
@Override
@@ -70,13 +72,13 @@ public class NamedBodyForcePair implements CosmicSystem {
@Override
public void addForceTo(CosmicSystem cs) {
cs.addForceFrom(body);
cs.addForceFrom(body.getBody());
}
@Override
public BodyLinkedList getBodies() {
BodyLinkedList list = new BodyLinkedList();
list.addFirst(body);
list.addFirst(body.getBody());
return list;
}