AB8/3 + AB8/4
This commit is contained in:
@@ -1,43 +1,41 @@
|
||||
import codedraw.CodeDraw;
|
||||
|
||||
public class NamedBody implements Massive {
|
||||
public class NamedBody extends Body {
|
||||
|
||||
private final String name;
|
||||
private final Body body;
|
||||
|
||||
/**
|
||||
* Initializes this with name, mass, current position and movement.
|
||||
*/
|
||||
public NamedBody(String name, double mass, Vector3 massCenter, Vector3 currentMovement) {
|
||||
this(name, new Body(mass, massCenter, currentMovement));
|
||||
super(mass, massCenter, currentMovement);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public NamedBody(String name, double mass) {
|
||||
super(mass);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public NamedBody(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public NamedBody(String name, Body body) {
|
||||
super(body);
|
||||
this.name = name;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public NamedBody(NamedBody other) {
|
||||
this(other.name, new Body(other.body));
|
||||
super(other);
|
||||
this.name = other.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the body.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Body getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public Vector3 getMassCenter() {
|
||||
return body.getMassCenter();
|
||||
}
|
||||
|
||||
public double getMass() {
|
||||
return body.getMass();
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,14 +64,4 @@ public class NamedBody implements Massive {
|
||||
public String toString() {
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(Vector3 force) {
|
||||
body.move(force);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(CodeDraw cd) {
|
||||
body.draw(cd);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user