Class FormulaManager

java.lang.Object
math.differentialcalculus.FormulaManager

public class FormulaManager extends Object
  • Field Details

    • FORMULAE

      private final ArrayList<Formula> FORMULAE
      Records all unique Formulae(no duplicates allowed) used by the function to be simplified.
  • Constructor Details

    • FormulaManager

      public FormulaManager()
  • Method Details

    • getFORMULAE

      public ArrayList<Formula> getFORMULAE()
    • count

      public int count()
      Returns:
      The number of Formula objects stored by an object of this class.
    • contains

      public boolean contains(String name)
      Parameters:
      name - The name of the Formula.
      Returns:
      true if a Formula exists by the name supplied.
    • comparisonData

      public Object[] comparisonData(List<String> data)
      THIS UTILITY METHOD CAN BE USED TO COMPARE THE DATA OF A FORMULA OBJECT WITH OTHER FORMULAE IN THE STORE TO SEE IF A FORMULA WITH SIMILAR DATA EXISTS ALREADY. ALSO, THE COMPARISON RETURNS MULTIPLE INFORMATION, NOT JUST ONE.
      Parameters:
      data - The data of the Formula.
      Returns:
      an array having 3 entries. Index 0 contains 0 if a comparable Formula is found in the store. A comparable Formula is one that is either a constant factor of this one or is equivalent to this one...i.e. they evaluate to the same number, always. If index 0 contains -1, then no comparable Formula exists in the store and so indices 1 and 2 will also be -1. Index 1 contains the index at which the comparable Formula is found. Index 2 contains the factor. If factor =1 , then they are equivalent, else,they are constant factors of each other.
    • indexOf

      public int indexOf(String name)
      Parameters:
      name - The name of the dependent variable of the Formula.
      Returns:
      the index of the Formula object that has the name supplied. If no such Formula object exists, then it returns -1.
    • getFormula

      public Formula getFormula(String name) throws ClassNotFoundException
      Parameters:
      name - The name of the Formula.
      Returns:
      the Formula object that has the name supplied if it exists. If no such Formula object exists, then it returns null.
      Throws:
      ClassNotFoundException - if no Formula object by that name exists.
    • getFormula

      public Formula getFormula(int index) throws ClassNotFoundException
      Parameters:
      index - The index of the Formula in this FormulaManager object. If no such index exists, then it returns null.
      Throws:
      ClassNotFoundException - if no Formula object by that name exists.
    • lookUp

      public Formula lookUp(String name)
      Attempts to retrieve a Formula object from a FormulaManager based on its name.
      Parameters:
      name - The name of the Formula object.
      Returns:
      the Formula object that has that name or null if the Formula is not found.
    • add

      public void add(Formula form)
      Parameters:
      form - The Formula object to add to this object.
    • delete

      public void delete(String name)
      Removes a Formula object from this FormulaManager.
    • firstFormula

      public Formula firstFormula()
    • lastFormula

      public Formula lastFormula()
    • update

      public int update(String name, String newName)
      It updates the name of a Formula object in this FormulaManager with the parameter newName.
      Parameters:
      name - The name of the Formula in this FormulaManager that we wish to update.
      newName - The new name to give the Formula.
      Returns:
      The index of the object, if a Formula by that name is already recorded in the FormulaManager and -1 the Formula is not found.
    • update

      public int update(String name, List<String> data)
      Updates a Formula object in this FormulaManager.
      Parameters:
      name - The name of the Formula object to be updated.
      data - The data to be used to update the object if found.
      Returns:
      The index of the object, if a Formula by that name is already recorded in the FormulaManager and -1 the Formula is not found.
    • clearAll

      public void clearAll()