Compare commits
1 Commits
Abgabe5
...
Abgabe5-Na
Author | SHA1 | Date | |
---|---|---|---|
a62ef91a8a |
@ -8,8 +8,8 @@ import codedraw.CodeDraw;
|
||||
public class HierarchicalSystem implements CosmicSystem {
|
||||
|
||||
private final NamedBodyForcePair central;
|
||||
private final CosmicSystem[] orbit;
|
||||
private final CosmicSystem[] all;
|
||||
private CosmicSystem[] orbit;
|
||||
private CosmicSystem[] all;
|
||||
|
||||
/**
|
||||
* Initializes this system with a name and a central body.
|
||||
@ -110,4 +110,21 @@ public class HierarchicalSystem implements CosmicSystem {
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the system 'cs' at the first place in the orbit of this system.
|
||||
* Precondition: cs != null
|
||||
*/
|
||||
public boolean putFirst(CosmicSystem cs) {
|
||||
CosmicSystem[] old = orbit;
|
||||
orbit = new CosmicSystem[old.length + 1];
|
||||
all = new CosmicSystem[old.length + 2];
|
||||
|
||||
orbit[0] = cs;
|
||||
System.arraycopy(old, 0, orbit, 1, old.length);
|
||||
all[0] = central;
|
||||
System.arraycopy(orbit, 0, all, 1, orbit.length);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user