Package it.unimi.di.prog2.s18
Class Star
java.lang.Object
it.unimi.di.prog2.s18.CelestialBody
it.unimi.di.prog2.s18.Star
- All Implemented Interfaces:
Comparable<CelestialBody>
A fixed star.
A fixed star is a CelestialBody
with fixed position and velocity (and energy equal to
0).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
energy()
Returns the total energy of this celestial body.toString()
void
Updates the position of this celestial body (usually following a change in its velocity).void
Updates the velocity of this celestial body.velocity()
Returns the velocity of this celestial body.
-
Constructor Details
-
Star
Constructs a fixed star.Constructs a fixed star given its name and position.
- Parameters:
nome
- 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 empty.
-
-
Method Details
-
velocity
Description copied from class:CelestialBody
Returns the velocity of this celestial body.- Specified by:
velocity
in classCelestialBody
- Returns:
- the velocity (not
null
}).
-
energy
public long energy()Description copied from class:CelestialBody
Returns the total energy of this celestial body.- Overrides:
energy
in classCelestialBody
- Returns:
- the energy.
-
updatePosition
public void updatePosition()Description copied from class:CelestialBody
Updates the position of this celestial body (usually following a change in its velocity).- Specified by:
updatePosition
in classCelestialBody
-
updateVelocity
Description copied from class:CelestialBody
Updates 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:
updateVelocity
in classCelestialBody
- Parameters:
c
- the celestial body to interact with.
-
toString
-