Class EnergySavedIndividual

Object
EnergySavedIndividual
All Implemented Interfaces:
Serializable, Iterable<EnergyTotal>

public class EnergySavedIndividual extends Object implements 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 Details

    • EnergySavedIndividual

      public EnergySavedIndividual()
  • Method Details

    • shallowCopy

      public EnergySavedIndividual shallowCopy()
      Creates a shallow copy of this instance.
      Returns:
      a new EnergySavedIndividual with a shallow copy of the energy totals
    • deepCopy

      public EnergySavedIndividual 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

      public EnergyTotal get(int index)
      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

      public void add(EnergyTotal item)
      Adds a new energy total to the list and updates the total energy.
      Parameters:
      item - the EnergyTotal 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

      public void exchange(int index, EnergyTotal item)
      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 exchange
      item - the new EnergyTotal to replace the existing one
    • describeMarks

      public String describeMarks(MarkCollection marks)
      Generates a string description of the marks and their associated energies.
      Parameters:
      marks - the MarkCollection 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

      public Iterator<EnergyTotal> iterator()
      Specified by:
      iterator in interface Iterable<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.