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 TypeMethodDescriptionvoidadd(EnergyTotal item) Adds a new energy total to the list and updates the total energy.voidAsserts 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.voidexchange(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.doubleThe total energy of all individual marks.iterator()voidresetInd()Resets the list of individual energy totals.voidrmv(int index) Removes an energy total at a specific index and updates the total energy.voidsetEnergyTotal(double energyTotal) The total energy of all individual marks.Creates a shallow copy of this instance.intsize()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, waitMethods 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
EnergySavedIndividualwith a shallow copy of the energy totals
-
deepCopy
Creates a deep copy of this instance.- Returns:
- a new
EnergySavedIndividualwith 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
EnergyTotalat 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- theEnergyTotalto 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 newEnergyTotalto replace the existing one
-
describeMarks
Generates a string description of the marks and their associated energies.- Parameters:
marks- theMarkCollectioncontaining 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:
iteratorin 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.
-