Class EnergySavedIndividual
Object
EnergySavedIndividual
- All Implemented Interfaces:
Serializable
,Iterable<EnergyTotal>
Stores and manages individual energy values for a collection of marks.
This class implements Serializable
for persistence and Iterable
for easy
iteration over energy values.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(EnergyTotal item) Adds a new energy total to the list and updates the total energy.void
Asserts that the total energy is valid (not NaN).deepCopy()
Creates a deep copy of this instance.describeMarks
(MarkCollection marks) Generates a string description of the marks and their associated energies.void
exchange
(int index, EnergyTotal item) Exchanges an energy total at a specific index with a new one and updates the total energy.get
(int index) Gets the energy total at a specific index.double
The total energy of all individual marks.iterator()
void
resetInd()
Resets the list of individual energy totals.void
rmv
(int index) Removes an energy total at a specific index and updates the total energy.void
setEnergyTotal
(double energyTotal) The total energy of all individual marks.Creates a shallow copy of this instance.int
size()
Gets the number of individual energy totals stored.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
EnergySavedIndividual
public EnergySavedIndividual()
-
-
Method Details
-
shallowCopy
Creates a shallow copy of this instance.- Returns:
- a new
EnergySavedIndividual
with a shallow copy of the energy totals
-
deepCopy
Creates a deep copy of this instance.- Returns:
- a new
EnergySavedIndividual
with a deep copy of the energy totals
-
size
public int size()Gets the number of individual energy totals stored.- Returns:
- the number of energy totals
-
get
Gets the energy total at a specific index.- Parameters:
index
- the index of the energy total to retrieve- Returns:
- the
EnergyTotal
at the specified index
-
resetInd
public void resetInd()Resets the list of individual energy totals. -
add
Adds a new energy total to the list and updates the total energy.- Parameters:
item
- theEnergyTotal
to add
-
rmv
public void rmv(int index) Removes an energy total at a specific index and updates the total energy.- Parameters:
index
- the index of the energy total to remove
-
exchange
Exchanges an energy total at a specific index with a new one and updates the total energy.- Parameters:
index
- the index of the energy total to exchangeitem
- the newEnergyTotal
to replace the existing one
-
describeMarks
Generates a string description of the marks and their associated energies.- Parameters:
marks
- theMarkCollection
containing the marks- Returns:
- a string representation of the marks and their energies
-
assertValid
public void assertValid()Asserts that the total energy is valid (not NaN). -
iterator
- Specified by:
iterator
in interfaceIterable<EnergyTotal>
-
getEnergyTotal
public double getEnergyTotal()The total energy of all individual marks. -
setEnergyTotal
public void setEnergyTotal(double energyTotal) The total energy of all individual marks.
-