Finished AB5
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user