Class FormulaManager


  • public class FormulaManager
    extends java.lang.Object
    Author:
    GBEMIRO
    • Constructor Summary

      Constructors 
      Constructor Description
      FormulaManager()  
    • Method Summary

      Modifier and Type Method Description
      void add​(Formula form)  
      void clearAll()  
      java.lang.Object[] comparisonData​(java.util.List<java.lang.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.
      boolean contains​(java.lang.String name)  
      int count()  
      void delete​(java.lang.String name)
      Removes a Formula object from this FormulaManager.
      Formula firstFormula()  
      Formula getFormula​(int index)  
      Formula getFormula​(java.lang.String name)  
      java.util.ArrayList<Formula> getFORMULAE()  
      int indexOf​(java.lang.String name)  
      Formula lastFormula()  
      Formula lookUp​(java.lang.String name)
      Attempts to retrieve a Formula object from a FormulaManager based on its name.
      int update​(java.lang.String name, java.lang.String newName)
      It updates the name of a Formula object in this FormulaManager with the parameter newName.
      int update​(java.lang.String name, java.util.List<java.lang.String> data)
      Updates a Formula object in this FormulaManager.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FormulaManager

        public FormulaManager()
    • Method Detail

      • getFORMULAE

        public java.util.ArrayList<Formula> getFORMULAE()
      • count

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

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

        public java.lang.Object[] comparisonData​(java.util.List<java.lang.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​(java.lang.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​(java.lang.String name)
                           throws java.lang.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:
        java.lang.ClassNotFoundException - if no Formula object by that name exists.
      • getFormula

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

        public Formula lookUp​(java.lang.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​(java.lang.String name)
        Removes a Formula object from this FormulaManager.
      • firstFormula

        public Formula firstFormula()
      • lastFormula

        public Formula lastFormula()
      • update

        public int update​(java.lang.String name,
                          java.lang.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​(java.lang.String name,
                          java.util.List<java.lang.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()