Class Planet
java.lang.Object
it.unimi.di.prog2.s17.CelestialBody
it.unimi.di.prog2.s17.Planet
- All Implemented Interfaces:
Comparable<CelestialBody>
A planet.
A planet is a CelestialBody with variable position and velocity.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
velocity
The velocity of this planet.
-
-
Constructor Details
-
Planet
Constructs a planet.Constructs a planet initially at rest (i.e., with a velocity of zero) given its name and initial position.
- Parameters:
name- the name.x- the x coordinate of the initial position.y- the y coordinate of the initial position.z- the z coordinate of the initial position.- Throws:
NullPointerException- if the name isnull.IllegalArgumentException- if the name is composed of only spaces, or is empty.
-
-
Method Details
-
velocity
Description copied from class:CelestialBodyReturns the velocity of this celestial body.- Specified by:
velocityin classCelestialBody- Returns:
- the velocity (not
null}).
-
updatePosition
public void updatePosition()Description copied from class:CelestialBodyUpdates the position of this celestial body (usually following a change in its velocity).- Specified by:
updatePositionin classCelestialBody
-
updateVelocity
Description copied from class:CelestialBodyUpdates the velocity of this celestial body.The velocity must be updated based on the interaction with the celestial body given as an argument according to what is illustrated in the overview of this package; this method must not modify the celestial body given as an argument.
- Specified by:
updateVelocityin classCelestialBody- Parameters:
c- the celestial body to interact with.
-
toString
-