Class LinearEquation


  • public class LinearEquation
    extends java.lang.Object
    A class for linear equations
    Author:
    Bhagat
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  LinearEquation.Term
      A class for each term in the equation
    • Field Summary

      Fields 
      Modifier and Type Field Description
      LinearEquation.Term[] terms
      An array of the terms in the linear equation
    • Constructor Summary

      Constructors 
      Constructor Description
      LinearEquation​(java.lang.String equation, java.lang.String... variables)
      Constructs a Linear Equation object from a string equation and a list of variables
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double getConstant()
      finds the constant in the equation
      java.util.ArrayList<java.lang.String> getVariables()
      creates a list of variables from the terms
      double getWeight​(java.lang.String variable)
      gets a weight for a specific variable
      Vector getWeights()
      gets all the weights that the variables are multiplied with in each term
      java.lang.String toString()
      converts back to a string equation
      • Methods inherited from class java.lang.Object

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

      • LinearEquation

        public LinearEquation​(java.lang.String equation,
                              java.lang.String... variables)
        Constructs a Linear Equation object from a string equation and a list of variables
        Parameters:
        equation - the string equation
        variables - the list of variables
    • Method Detail

      • getVariables

        public java.util.ArrayList<java.lang.String> getVariables()
        creates a list of variables from the terms
        Returns:
        the variables
      • getWeights

        public Vector getWeights()
        gets all the weights that the variables are multiplied with in each term
        Returns:
        a vector containing the weights
      • getWeight

        public double getWeight​(java.lang.String variable)
        gets a weight for a specific variable
        Parameters:
        variable - the variable
        Returns:
        the weight
      • getConstant

        public double getConstant()
        finds the constant in the equation
        Returns:
        the constant
      • toString

        public java.lang.String toString()
        converts back to a string equation
        Overrides:
        toString in class java.lang.Object