Class : Monom - VadimKachevski/OOP_Ex1 GitHub Wiki

This Class can hold a single Monom that is represneted in the way : aX^b


a - is a Double and represent the coefficient. b - is a Integer and represent the power of the X.

You can build this Monom using a coefficient and a power, or a String. the String must be in a valid format of a Monom. Good examples:

  • "3x^2"
  • "x"
  • "1"
  • "0.5x^5"

Bad examples:

  • "3xx^2"
  • "3..2x"
  • "3x^2.2"

The methods that can be used with a Monom object: the initial getters and setters for the coeffienct and power.

  • f(x) - returns the value Y of the Monom with the given x.
  • derivative() - returns a Monom representing the derivative of the Monom.
  • isZero() - returns boolean value if the Monom is a zero Monom.
  • add(Monom m) - adding the currnent Monom with the given Monom, the Monoms must be with the same power.
  • substract(Monom m) - substructing the current Monom with the given Monom, the Monoms must be with the same power.
  • multipy(Monom d) - multiplying the current monom with the given Monom.
  • equals(Object other) - returns a boolean value if the current Monom is equal logically to the Other object,must be a Function.
  • String toString() - returns the string value of the Monom.
  • initFromString(String s) - returns a function created from the given String.
  • copy() - returns a function that is a deep copy of the current Monom.